mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 22:21:42 +00:00
Various code cleanup.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user