Code cleanup and realign.

This commit is contained in:
James Cole
2018-08-06 19:14:30 +02:00
parent f7eef25fed
commit 5908c0ce8c
188 changed files with 1019 additions and 1031 deletions

View File

@@ -56,7 +56,7 @@ class Amount
$space = ' ';
// require space between symbol and amount?
if ($sepBySpace === false) {
if (false === $sepBySpace) {
$space = ''; // no
}
@@ -134,8 +134,8 @@ class Amount
// some complicated switches to format the amount correctly:
$precedes = $amount < 0 ? $info['n_cs_precedes'] : $info['p_cs_precedes'];
$separated = $amount < 0 ? $info['n_sep_by_space'] : $info['p_sep_by_space'];
$space = $separated === true ? ' ' : '';
$result = $precedes === false ? $formatted . $space . $format->symbol : $format->symbol . $space . $formatted;
$space = true === $separated ? ' ' : '';
$result = false === $precedes ? $formatted . $space . $format->symbol : $format->symbol . $space . $formatted;
if (true === $coloured) {
if ($amount > 0) {

View File

@@ -59,7 +59,7 @@ class SelectBudgetHandler implements YnabJobConfigurationInterface
Log::debug('Now in SelectBudgetHandler::configComplete');
$configuration = $this->repository->getConfiguration($this->importJob);
$selectedBudget = $configuration['selected_budget'] ?? '';
if ($selectedBudget !== '') {
if ('' !== $selectedBudget) {
Log::debug(sprintf('Selected budget is %s, config is complete. Return true.', $selectedBudget));
$this->repository->setStage($this->importJob, 'get_accounts');

View File

@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Support\Import\JobConfiguration\Ynab;
use FireflyIII\Models\ImportJob;
use Illuminate\Support\MessageBag;

View File

@@ -147,6 +147,7 @@ class ImportableConverter
Log::error($e->getTraceAsString());
}
}
return $result;
}

View File

@@ -150,7 +150,7 @@ class ImportDataHandler
$destination = $this->mapper->map($possibleDestinationId, $amount, $destinationData);
if (1 === bccomp($amount, '0')) {
[$source, $destination] = [$destination, $source];
$type = $type === 'transfer' ? 'transfer' : 'deposit';
$type = 'transfer' === $type ? 'transfer' : 'deposit';
Log::debug(sprintf('Amount is %s, so switch source/dest and make this a %s', $amount, $type));
}

View File

@@ -70,14 +70,14 @@ class StageGetAccessHandler
}
$statusCode = $res->getStatusCode();
try {
$content = trim($res->getBody()->getContents());
} catch(RuntimeException $e) {
$content = trim($res->getBody()->getContents());
} catch (RuntimeException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
throw new FireflyException($e->getMessage());
}
$json = json_decode($content, true) ?? [];
$json = json_decode($content, true) ?? [];
Log::debug(sprintf('Status code from YNAB is %d', $statusCode));
Log::debug(sprintf('Body of result is %s', $content), $json);

View File

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

View File

@@ -171,6 +171,7 @@ class Preferences
if (\is_array($lastActivity)) {
$lastActivity = implode(',', $lastActivity);
}
return md5($lastActivity);
}

View File

@@ -46,7 +46,7 @@ class General extends Twig_Extension
$this->balance(),
$this->formatFilesize(),
$this->mimeIcon(),
$this->markdown()
$this->markdown(),
];
}
@@ -249,6 +249,7 @@ class General extends Twig_Extension
if ($repository->hasRole(auth()->user(), $role)) {
return true;
}
return false;
}
);

View File

@@ -69,7 +69,6 @@ class Translation extends Twig_Extension
'journalLinkTranslation',
function (string $direction, string $original) {
$key = sprintf('firefly.%s_%s', $original, $direction);
return $key;
$translation = trans($key);
if ($key === $translation) {