Various code cleanup.

This commit is contained in:
James Cole
2018-07-27 05:03:37 +02:00
parent 0312ba8ad7
commit e3e0e12fef
43 changed files with 167 additions and 145 deletions

View File

@@ -57,7 +57,7 @@ class StageAuthenticatedHandler
$config = $this->importJob->configuration;
$logins = $config['all-logins'] ?? [];
Log::debug(sprintf('%d logins in config', \count($logins)));
if (\count($logins) === 0) {
if (0 === \count($logins)) {
// get logins from Spectre.
$logins = $this->getLogins();
$config['all-logins'] = $logins;

View File

@@ -60,7 +60,7 @@ class StageImportDataHandler
$config = $this->importJob->configuration;
$accounts = $config['accounts'] ?? [];
Log::debug(sprintf('Count of accounts in array is %d', \count($accounts)));
if (\count($accounts) === 0) {
if (0 === \count($accounts)) {
throw new FireflyException('There are no accounts in this import job. Cannot continue.'); // @codeCoverageIgnore
}
$toImport = $config['account_mapping'] ?? [];
@@ -124,14 +124,14 @@ class StageImportDataHandler
$amount = $transaction->getAmount();
$source = $originalSource;
$destination = $this->mapper->map(null, $amount, $destinationData);
$notes = (string)trans('import.imported_from_account', ['account' => $spectreAccount->getName()]) . ' ' . "\n";
$notes = trans('import.imported_from_account', ['account' => $spectreAccount->getName()]) . ' ' . "\n";
$foreignAmount = null;
$foreignCurrencyCode = null;
$currencyCode = $transaction->getCurrencyCode();
$type = 'withdrawal';
// switch source and destination if amount is greater than zero.
if (bccomp($amount, '0') === 1) {
if (1 === bccomp($amount, '0')) {
[$source, $destination] = [$destination, $source];
$type = 'deposit';
}