Code cleanup before release.

This commit is contained in:
James Cole
2018-03-29 19:01:47 +02:00
parent 40266c6821
commit 170d23d768
76 changed files with 181 additions and 171 deletions

View File

@@ -114,7 +114,7 @@ class Amount implements ConverterInterface
$str = preg_replace('/[^\-\(\)\.\,0-9 ]/', '', $value);
$len = strlen($str);
if ('(' === $str[0] && ')' === $str[$len - 1]) {
$str = '-' . substr($str, 1, ($len - 2));
$str = '-' . substr($str, 1, $len - 2);
}
Log::debug(sprintf('Stripped "%s" away to "%s"', $value, $str));

View File

@@ -281,9 +281,8 @@ class CsvProcessor implements FileProcessorInterface
if (false === $json) {
throw new FireflyException(sprintf('Error while encoding JSON for CSV row: %s', $this->getJsonError($jsonError))); // @codeCoverageIgnore
}
$hash = hash('sha256', $json);
return $hash;
return hash('sha256', $json);
}
/**
@@ -340,11 +339,8 @@ class CsvProcessor implements FileProcessorInterface
{
$hash = $this->getRowHash($array);
$count = $this->repository->countByHash($hash);
if ($count > 0) {
return true;
}
return false;
return $count > 0;
}
/**

View File

@@ -54,7 +54,7 @@ class CommandHandler extends AbstractProcessingHandler
*/
protected function write(array $record)
{
$this->command->line((string)trim($record['formatted']));
$this->command->line(trim($record['formatted']));
}
/**

View File

@@ -53,6 +53,7 @@ class AssetAccountIbans implements MapperInterface
$list[$accountId] = $account->name;
}
}
/** @noinspection AdditionOperationOnArraysInspection */
$list = $topList + $list;
asort($list);
$list = [0 => trans('import.map_do_not_map')] + $list;

View File

@@ -183,7 +183,7 @@ class ImportJournal
$converter = app($class);
Log::debug(sprintf('Now launching converter %s', $class));
if ($converter->convert($modifier['value']) === -1) {
$this->convertedAmount = Steam::negative($amount);
$amount = Steam::negative($amount);
}
Log::debug(sprintf('Foreign amount after conversion is %s', $amount));
}
@@ -478,7 +478,5 @@ class ImportJournal
$preProcessor = app(sprintf('\FireflyIII\Import\MapperPreProcess\%s', $preProcessorClass));
$tags = $preProcessor->run($array['value']);
$this->tags = array_merge($this->tags, $tags);
return;
}
}

View File

@@ -226,8 +226,6 @@ class BunqRoutine implements RoutineInterface
$config['stage'] = 'registered';
$this->setConfig($config);
$this->addStep();
return;
}
/**
@@ -319,6 +317,8 @@ class BunqRoutine implements RoutineInterface
* @param string $expectedType
*
* @return Account
* @throws \FireflyIII\Exceptions\FireflyException
* @throws FireflyException
*/
private function convertToAccount(LabelMonetaryAccount $party, string $expectedType): Account
{

View File

@@ -266,8 +266,6 @@ class FileRoutine implements RoutineInterface
private function setExtendedStatus(array $extended): void
{
$this->repository->setExtendedStatus($this->job, $extended);
return;
}
/**

View File

@@ -343,8 +343,6 @@ class SpectreRoutine implements RoutineInterface
$this->setConfig($config);
$this->setStatus('configuring');
$this->addStep();
return;
}
/**
@@ -468,7 +466,7 @@ class SpectreRoutine implements RoutineInterface
// various meta fields:
$importJournal->setValue(['role' => 'category-name', 'value' => $transaction->getCategory()]);
$importJournal->setValue(['role' => 'note', 'value' => $notes]);
$importJournal->setValue(['role' => 'tags-comma', 'value' => join(',', $tags)]);
$importJournal->setValue(['role' => 'tags-comma', 'value' => implode(',', $tags)]);
$collection->push($importJournal);
}
}
@@ -521,7 +519,6 @@ class SpectreRoutine implements RoutineInterface
$this->setStatus('finished');
$this->addStep();
return;
}
/**
@@ -538,7 +535,7 @@ class SpectreRoutine implements RoutineInterface
/** @var array $accountArray */
foreach ($accounts as $accountArray) {
$account = new Account($accountArray);
$importId = intval($config['accounts-mapped'][$account->getid()] ?? 0);
$importId = intval($config['accounts-mapped'][$account->getId()] ?? 0);
$doImport = 0 !== $importId ? true : false;
if (!$doImport) {
Log::debug(sprintf('Will NOT import from Spectre account #%d ("%s")', $account->getId(), $account->getName()));
@@ -571,7 +568,6 @@ class SpectreRoutine implements RoutineInterface
{
$this->repository->setConfiguration($this->job, $config);
return;
}
/**
@@ -583,7 +579,6 @@ class SpectreRoutine implements RoutineInterface
{
$this->repository->setExtendedStatus($this->job, $extended);
return;
}
/**

View File

@@ -182,7 +182,7 @@ class ImportStorage
*/
protected function storeImportJournal(int $index, ImportJournal $importJournal): bool
{
Log::debug(sprintf('Going to store object #%d/%d with description "%s"', ($index + 1), $this->total, $importJournal->getDescription()));
Log::debug(sprintf('Going to store object #%d/%d with description "%s"', $index + 1, $this->total, $importJournal->getDescription()));
$assetAccount = $importJournal->asset->getAccount();
$amount = $importJournal->getAmount();
$foreignAmount = $importJournal->getForeignAmount();
@@ -370,7 +370,7 @@ class ImportStorage
}
if ($names === $transfer['names']) {
++$hits;
Log::debug(sprintf('Involved accounts, "%s" equals "%s", hits = %d', join(',', $names), join(',', $transfer['names']), $hits));
Log::debug(sprintf('Involved accounts, "%s" equals "%s", hits = %d', implode(',', $names), implode(',', $transfer['names']), $hits));
}
if (0 === bccomp($amount, $transfer['amount'])) {
++$hits;

View File

@@ -62,6 +62,7 @@ trait ImportSupport
* @param TransactionJournal $journal
*
* @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/
protected function applyRules(TransactionJournal $journal): bool
{
@@ -279,6 +280,7 @@ trait ImportSupport
* is not already present.
*
* @return array
* @throws \InvalidArgumentException
*/
private function getTransfers(): array
{