Big refactor to remove the deprecated transaction collector.

This commit is contained in:
James Cole
2019-05-30 12:31:19 +02:00
parent 10a6ff9bf8
commit 8b7e87ae57
117 changed files with 1314 additions and 1208 deletions

View File

@@ -325,7 +325,7 @@ class StageImportDataHandler
/*
* After the loop, check if Firefly III must loop again.
*/
Log::debug(sprintf('Count of result is now %d', \count($return)));
Log::debug(sprintf('Count of result is now %d', count($return)));
$count++;
if (null === $olderId) {
Log::debug('Older ID is NULL, so stop looping cause we are done!');
@@ -351,7 +351,7 @@ class StageImportDataHandler
// store newest and oldest tranasction ID to be used later:
\Preferences::setForUser($this->importJob->user, sprintf('bunq-oldest-transaction-%d', $bunqAccountId), $oldestTransaction);
\Preferences::setForUser($this->importJob->user, sprintf('bunq-newest-transaction-%d', $bunqAccountId), $newestTransaction);
Log::info(sprintf('Downloaded and parsed %d transactions from bunq.', \count($return)));
Log::info(sprintf('Downloaded and parsed %d transactions from bunq.', count($return)));
return $return;
}
@@ -428,7 +428,7 @@ class StageImportDataHandler
/*
* After the loop, check if Firefly III must loop again.
*/
Log::debug(sprintf('Count of result is now %d', \count($return)));
Log::debug(sprintf('Count of result is now %d', count($return)));
$count++;
if (null === $newerId) {
Log::debug('Newer ID is NULL, so stop looping cause we are done!');
@@ -446,7 +446,7 @@ class StageImportDataHandler
// store newest tranasction ID to be used later:
\Preferences::setForUser($this->importJob->user, sprintf('bunq-newest-transaction-%d', $bunqAccountId), $newestTransaction);
Log::info(sprintf('Downloaded and parsed %d transactions from bunq.', \count($return)));
Log::info(sprintf('Downloaded and parsed %d transactions from bunq.', count($return)));
return $return;
}

View File

@@ -145,7 +145,7 @@ class StageNewHandler
}
}
}
Log::info(sprintf('Found %d account(s) at bunq', \count($accounts)), $accounts);
Log::info(sprintf('Found %d account(s) at bunq', count($accounts)), $accounts);
return $accounts;
}
@@ -224,7 +224,7 @@ class StageNewHandler
Log::debug('Setting is not null.');
}
if (null !== $maj->getAlias()) {
Log::debug(sprintf('Alias is not NULL. Count is %d', \count($maj->getAlias())));
Log::debug(sprintf('Alias is not NULL. Count is %d', count($maj->getAlias())));
/** @var Pointer $alias */
foreach ($maj->getAlias() as $alias) {
$return['aliases'][] = [
@@ -239,7 +239,7 @@ class StageNewHandler
}
}
$coOwners = $maj->getAllCoOwner() ?? [];
Log::debug(sprintf('Count of getAllCoOwner is %d', \count($coOwners)));
Log::debug(sprintf('Count of getAllCoOwner is %d', count($coOwners)));
/** @var CoOwner $coOwner */
foreach ($coOwners as $coOwner) {
$alias = $coOwner->getAlias();

View File

@@ -69,7 +69,7 @@ class ImportableConverter
*/
public function convert(array $importables): array
{
$total = \count($importables);
$total = count($importables);
Log::debug(sprintf('Going to convert %d import transactions', $total));
$result = [];
/** @var ImportTransaction $importable */

View File

@@ -90,7 +90,7 @@ class MappedValuesValidator
foreach ($mappings as $role => $values) {
Log::debug(sprintf('Now at role "%s"', $role));
$values = array_unique($values);
if (\count($values) > 0) {
if (count($values) > 0) {
switch ($role) {
default:
throw new FireflyException(sprintf('Cannot validate mapped values for role "%s"', $role)); // @codeCoverageIgnore

View File

@@ -69,7 +69,7 @@ class MappingConverger
{
Log::debug('Start converging process.');
$collection = [];
$total = \count($lines);
$total = count($lines);
/** @var array $line */
foreach ($lines as $lineIndex => $line) {
Log::debug(sprintf('Now converging line %d out of %d.', $lineIndex + 1, $total));

View File

@@ -56,8 +56,8 @@ class StageAuthenticatedHandler
// grab a list of logins.
$config = $this->importJob->configuration;
$logins = $config['all-logins'] ?? [];
Log::debug(sprintf('%d logins in config', \count($logins)));
if (0 === \count($logins)) {
Log::debug(sprintf('%d logins in config', count($logins)));
if (0 === count($logins)) {
// get logins from Spectre.
$logins = $this->getLogins();
$config['all-logins'] = $logins;
@@ -115,7 +115,7 @@ class StageAuthenticatedHandler
$request->setLogin($login);
$request->call();
$accounts = $request->getAccounts();
Log::debug(sprintf('Found %d accounts using login', \count($accounts)));
Log::debug(sprintf('Found %d accounts using login', count($accounts)));
return $accounts;
}
@@ -137,7 +137,7 @@ class StageAuthenticatedHandler
$logins = $request->getLogins();
$return = [];
Log::debug(sprintf('Found %d logins in users Spectre account.', \count($logins)));
Log::debug(sprintf('Found %d logins in users Spectre account.', count($logins)));
/** @var Login $login */
foreach ($logins as $login) {

View File

@@ -59,8 +59,8 @@ class StageImportDataHandler
Log::debug('Now in StageImportDataHandler::run()');
$config = $this->importJob->configuration;
$accounts = $config['accounts'] ?? [];
Log::debug(sprintf('Count of accounts in array is %d', \count($accounts)));
if (0 === \count($accounts)) {
Log::debug(sprintf('Count of accounts in array is %d', count($accounts)));
if (0 === count($accounts)) {
throw new FireflyException('There are no accounts in this import job. Cannot continue.'); // @codeCoverageIgnore
}
$toImport = $config['account_mapping'] ?? [];
@@ -73,14 +73,14 @@ class StageImportDataHandler
$merge = $this->getTransactions($spectreAccount, $localAccount);
$totalSet[] = $merge;
Log::debug(
sprintf('Found %d transactions in account "%s" (%s)', \count($merge), $spectreAccount->getName(), $spectreAccount->getCurrencyCode())
sprintf('Found %d transactions in account "%s" (%s)', count($merge), $spectreAccount->getName(), $spectreAccount->getCurrencyCode())
);
continue;
}
Log::debug(sprintf('Local account is = zero, will not import from Spectr account with ID #%d', $spectreId));
}
$totalSet = array_merge(...$totalSet);
Log::debug(sprintf('Found %d transactions in total.', \count($totalSet)));
Log::debug(sprintf('Found %d transactions in total.', count($totalSet)));
$this->repository->setTransactions($this->importJob, $totalSet);
}
@@ -112,8 +112,8 @@ class StageImportDataHandler
private function convertToArray(array $transactions, SpectreAccount $spectreAccount, LocalAccount $originalSource): array
{
$array = [];
$total = \count($transactions);
Log::debug(sprintf('Now in StageImportDataHandler::convertToArray() with count %d', \count($transactions)));
$total = count($transactions);
Log::debug(sprintf('Now in StageImportDataHandler::convertToArray() with count %d', count($transactions)));
/** @var SpectreTransaction $transaction */
foreach ($transactions as $index => $transaction) {
Log::debug(sprintf('Now creating array for transaction %d of %d', $index + 1, $total));
@@ -216,7 +216,7 @@ class StageImportDataHandler
];
$array[] = $entry;
}
Log::debug(sprintf('Return %d entries', \count($array)));
Log::debug(sprintf('Return %d entries', count($array)));
return $array;
}

View File

@@ -80,7 +80,7 @@ class StageNewHandler
$list = $request->getLogins();
// count is zero?
$this->countLogins = \count($list);
$this->countLogins = count($list);
Log::debug(sprintf('Number of logins is %d', $this->countLogins));
if ($this->countLogins > 0) {
$store = [];

View File

@@ -63,7 +63,7 @@ class GetAccountsHandler
$request->call();
$config['accounts'] = $request->accounts;
$this->repository->setConfiguration($this->importJob, $config);
if (0 === \count($config['accounts'])) {
if (0 === count($config['accounts'])) {
throw new FireflyException('This budget contains zero accounts.');
}
}

View File

@@ -78,7 +78,7 @@ class ImportDataHandler
}
$totalSet = array_merge(...$total);
Log::debug(sprintf('Found %d transactions in total.', \count($totalSet)));
Log::debug(sprintf('Found %d transactions in total.', count($totalSet)));
$this->repository->setTransactions($this->importJob, $totalSet);
// assuming this works, store today's date as a preference
@@ -114,9 +114,9 @@ class ImportDataHandler
{
$config = $this->repository->getConfiguration($this->importJob);
$array = [];
$total = \count($transactions);
$total = count($transactions);
$budget = $this->getSelectedBudget();
Log::debug(sprintf('Now in StageImportDataHandler::convertToArray() with count %d', \count($transactions)));
Log::debug(sprintf('Now in StageImportDataHandler::convertToArray() with count %d', count($transactions)));
/** @var array $transaction */
foreach ($transactions as $index => $transaction) {
$description = $transaction['memo'] ?? '(empty)';

View File

@@ -57,8 +57,8 @@ class StageGetBudgetsHandler
// store budgets in users preferences.
$configuration['budgets'] = $request->budgets;
$this->repository->setConfiguration($this->importJob, $configuration);
Log::debug(sprintf('Found %d budgets', \count($request->budgets)));
if (0 === \count($request->budgets)) {
Log::debug(sprintf('Found %d budgets', count($request->budgets)));
if (0 === count($request->budgets)) {
throw new FireflyException('It seems this user has zero budgets or an error prevented Firefly III from reading them.');
}
}