mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-07 14:41:20 +00:00
Refactor findNull to find
This commit is contained in:
@@ -130,17 +130,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$query->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
// See reference nr. 9
|
||||
|
||||
$accounts = $query->get(['accounts.*']);
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
if ($account->iban === $iban) {
|
||||
return $account;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return $query->where('iban', $iban)->first(['accounts.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +151,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
$accounts = $query->get(['accounts.*']);
|
||||
|
||||
// See reference nr. 10
|
||||
// See reference nr. 10
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
@@ -181,7 +171,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
public function findNull(int $accountId): ?Account
|
||||
public function find(int $accountId): ?Account
|
||||
{
|
||||
return $this->user->accounts()->find($accountId);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ interface AccountRepositoryInterface
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
public function findNull(int $accountId): ?Account;
|
||||
public function find(int $accountId): ?Account;
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
|
||||
@@ -207,7 +207,7 @@ class AccountTasker implements AccountTaskerInterface
|
||||
$sourceId = (int)$journal['destination_account_id'];
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$key = sprintf('%s-%s', $sourceId, $currencyId);
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->findNull($currencyId);
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->find($currencyId);
|
||||
$report['accounts'][$key] = $report['accounts'][$key] ?? [
|
||||
'id' => $sourceId,
|
||||
'name' => $journal['destination_account_name'],
|
||||
@@ -269,7 +269,7 @@ class AccountTasker implements AccountTaskerInterface
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$key = sprintf('%s-%s', $sourceId, $currencyId);
|
||||
if (!array_key_exists($key, $report['accounts'])) {
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->findNull($currencyId);
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->find($currencyId);
|
||||
$report['accounts'][$key] = [
|
||||
'id' => $sourceId,
|
||||
'name' => $journal['source_account_name'],
|
||||
|
||||
Reference in New Issue
Block a user