mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 12:11:19 +00:00
Various code cleanup.
This commit is contained in:
@@ -45,7 +45,7 @@ trait DepositValidation
|
||||
if (null === $accountId && null === $accountName && null === $accountIban && false === $this->canCreateTypes($validTypes)) {
|
||||
// if both values are NULL we return false,
|
||||
// because the destination of a deposit can't be created.
|
||||
$this->destError = (string)trans('validation.deposit_dest_need_data');
|
||||
$this->destError = (string) trans('validation.deposit_dest_need_data');
|
||||
app('log')->error('Both values are NULL, cant create deposit destination.');
|
||||
$result = false;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ trait DepositValidation
|
||||
$search = $this->findExistingAccount($validTypes, $array);
|
||||
if (null === $search) {
|
||||
app('log')->debug('findExistingAccount() returned NULL, so the result is false.');
|
||||
$this->destError = (string)trans('validation.deposit_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
$this->destError = (string) trans('validation.deposit_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
$result = false;
|
||||
}
|
||||
if (null !== $search) {
|
||||
@@ -78,6 +78,12 @@ trait DepositValidation
|
||||
|
||||
abstract protected function findExistingAccount(array $validTypes, array $data): ?Account;
|
||||
|
||||
/**
|
||||
* Pretty complex unfortunately.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
protected function validateDepositSource(array $array): bool
|
||||
{
|
||||
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
|
||||
@@ -100,7 +106,7 @@ trait DepositValidation
|
||||
// if both values are NULL return false,
|
||||
// because the source of a deposit can't be created.
|
||||
// (this never happens).
|
||||
$this->sourceError = (string)trans('validation.deposit_source_need_data');
|
||||
$this->sourceError = (string) trans('validation.deposit_source_need_data');
|
||||
$result = false;
|
||||
}
|
||||
|
||||
@@ -109,7 +115,7 @@ trait DepositValidation
|
||||
app('log')->debug('Check if there is not already another account with this IBAN');
|
||||
$existing = $this->findExistingAccount($validTypes, ['iban' => $accountIban], true);
|
||||
if (null !== $existing) {
|
||||
$this->sourceError = (string)trans('validation.deposit_src_iban_exists');
|
||||
$this->sourceError = (string) trans('validation.deposit_src_iban_exists');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user