Code cleanup.

This commit is contained in:
James Cole
2021-03-28 11:46:23 +02:00
parent 2c575f3ca5
commit b5eeacc128
124 changed files with 1568 additions and 1384 deletions

View File

@@ -291,6 +291,31 @@ class DoubleController extends Controller
return prefixView('reports.double.partials.accounts', compact('sums', 'report'));
}
/**
* TODO this method is double.
*
* @param Collection $accounts
* @param int $id
* @param string $name
* @param string|null $iban
*
* @return string
*/
private function getCounterpartName(Collection $accounts, int $id, string $name, ?string $iban): string
{
/** @var Account $account */
foreach ($accounts as $account) {
if ($account->name === $name && $account->id !== $id) {
return $account->name;
}
if (null !== $account->iban && $account->iban === $iban && $account->id !== $id) {
return $account->iban;
}
}
return $name;
}
/**
* @param Collection $accounts
* @param Collection $double
@@ -490,29 +515,4 @@ class DoubleController extends Controller
return $result;
}
/**
* TODO this method is double.
*
* @param Collection $accounts
* @param int $id
* @param string $name
* @param string|null $iban
*
* @return string
*/
private function getCounterpartName(Collection $accounts, int $id, string $name, ?string $iban): string
{
/** @var Account $account */
foreach ($accounts as $account) {
if ($account->name === $name && $account->id !== $id) {
return $account->name;
}
if (null !== $account->iban && $account->iban === $iban && $account->id !== $id) {
return $account->iban;
}
}
return $name;
}
}