Code cleanup.

This commit is contained in:
James Cole
2023-12-20 19:35:52 +01:00
parent c4f6366642
commit 64ec0cf62e
997 changed files with 12908 additions and 28136 deletions

View File

@@ -43,8 +43,6 @@ class FixIbans extends Command
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
@@ -58,11 +56,6 @@ class FixIbans extends Command
return 0;
}
/**
* @param Collection $accounts
*
* @return void
*/
private function filterIbans(Collection $accounts): void
{
/** @var Account $account */
@@ -74,20 +67,16 @@ class FixIbans extends Command
$account->iban = $iban;
$account->save();
$this->friendlyInfo(sprintf('Removed spaces from IBAN of account #%d', $account->id));
$this->count++;
++$this->count;
}
}
}
}
/**
* @param Collection $accounts
*
* @return void
*/
private function countAndCorrectIbans(Collection $accounts): void
{
$set = [];
/** @var Account $account */
foreach ($accounts as $account) {
$userId = $account->user_id;
@@ -103,9 +92,8 @@ class FixIbans extends Command
if (array_key_exists($iban, $set[$userId])) {
// iban already in use! two exceptions exist:
if (
!(AccountType::EXPENSE === $set[$userId][$iban] && AccountType::REVENUE === $type)
&& // allowed combination
!(AccountType::REVENUE === $set[$userId][$iban] && AccountType::EXPENSE === $type) // also allowed combination.
!(AccountType::EXPENSE === $set[$userId][$iban] && AccountType::REVENUE === $type) // allowed combination
&& !(AccountType::REVENUE === $set[$userId][$iban] && AccountType::EXPENSE === $type) // also allowed combination.
) {
$this->friendlyWarning(
sprintf(
@@ -118,7 +106,7 @@ class FixIbans extends Command
);
$account->iban = null;
$account->save();
$this->count++;
++$this->count;
}
}