Various code cleanup.

This commit is contained in:
James Cole
2021-04-07 07:28:43 +02:00
parent 4ddcb0c965
commit f12744ad8c
180 changed files with 714 additions and 721 deletions

View File

@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Repositories\Journal;
use Carbon\Carbon;
use DB;
use Exception;
@@ -29,7 +30,6 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Support\CacheProperties;
use FireflyIII\User;
use Illuminate\Support\Collection;
use Log;
use stdClass;
/**
@@ -128,9 +128,9 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
if ($cache->has()) {
$result = null;
try {
$result = new Carbon($cache->get()); // @codeCoverageIgnore
} catch (Exception $e) {
$e->getMessage();
$result = new Carbon($cache->get());
} catch (Exception $e) { // @phpstan-ignore-line
// @ignoreException
}
return $result;
@@ -143,13 +143,12 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
$value = null;
try {
$value = new Carbon($entry->data);
} catch (Exception $e) {
$e->getMessage();
return null;
} catch (Exception $e) { // @phpstan-ignore-line
// @ignoreException
}
if (null !== $value) {
$cache->store($value);
}
$cache->store($entry->data);
return $value;
}
@@ -170,7 +169,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
$cache->addProperty($field);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
$entry = $journal->transactionJournalMeta()->where('name', $field)->first();
@@ -188,13 +187,11 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
}
// return when something else:
$return = (string)$value;
try {
$return = (string)$value;
$cache->store($return);
} catch (Exception $e) {
Log::error($e->getMessage());
return '';
} catch (Exception $e) { // @phpstan-ignore-line
// @ignoreException
}
return $return;

View File

@@ -137,7 +137,7 @@ class JournalRepository implements JournalRepositoryInterface
$cache->addProperty($journal->id);
$cache->addProperty('destination-account-list');
if ($useCache && $cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
$transactions = $journal->transactions()->where('amount', '>', 0)->orderBy('transactions.account_id')->with('account')->get();
$list = new Collection;
@@ -165,7 +165,7 @@ class JournalRepository implements JournalRepositoryInterface
$cache->addProperty($journal->id);
$cache->addProperty('source-account-list');
if ($useCache && $cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
$transactions = $journal->transactions()->where('amount', '<', 0)->orderBy('transactions.account_id')->with('account')->get();
$list = new Collection;
@@ -192,7 +192,7 @@ class JournalRepository implements JournalRepositoryInterface
$cache->addProperty($journal->id);
$cache->addProperty('amount-positive');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
// saves on queries:
@@ -250,7 +250,7 @@ class JournalRepository implements JournalRepositoryInterface
$cache->addProperty($field);
if ($cache->has()) {
return new Carbon($cache->get()); // @codeCoverageIgnore
return new Carbon($cache->get());
}
$entry = TransactionJournalMeta::where('transaction_journal_id', $journalId)
->where('name', $field)->first();