Code cleanup

This commit is contained in:
James Cole
2021-03-21 09:15:40 +01:00
parent da1751940e
commit 206845575c
317 changed files with 7418 additions and 7362 deletions

View File

@@ -119,21 +119,21 @@ class AccountUpdateService
private function updateAccount(Account $account, array $data): Account
{
// update the account itself:
if(array_key_exists('name', $data)) {
$account->name = $data['name'];
if (array_key_exists('name', $data)) {
$account->name = $data['name'];
}
if(array_key_exists('active', $data)) {
if (array_key_exists('active', $data)) {
$account->active = $data['active'];
}
if(array_key_exists('iban', $data)) {
$account->iban = $data['iban'];
if (array_key_exists('iban', $data)) {
$account->iban = $data['iban'];
}
// set liability, but account must already be a liability.
//$liabilityType = $data['liability_type'] ?? '';
if ($this->isLiability($account) && array_key_exists('liability_type', $data)) {
$type = $this->getAccountType($data['liability_type']);
if(null !== $type) {
$type = $this->getAccountType($data['liability_type']);
if (null !== $type) {
$account->account_type_id = $type->id;
}
}
@@ -160,20 +160,6 @@ class AccountUpdateService
return in_array($type, [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE], true);
}
/**
* @param string $type
*
* @return bool
*/
private function isLiabilityType(string $type): bool
{
if ('' === $type) {
return false;
}
return 1 === AccountType::whereIn('type', [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE])->where('type', ucfirst($type))->count();
}
/**
* @param string $type
*/
@@ -334,4 +320,18 @@ class AccountUpdateService
}
Log::debug('Account was not marked as inactive, do nothing.');
}
/**
* @param string $type
*
* @return bool
*/
private function isLiabilityType(string $type): bool
{
if ('' === $type) {
return false;
}
return 1 === AccountType::whereIn('type', [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE])->where('type', ucfirst($type))->count();
}
}