chore: code cleanup.

This commit is contained in:
James Cole
2023-05-29 13:56:55 +02:00
parent 7f7644c92f
commit 1b52147a05
295 changed files with 12418 additions and 12324 deletions

View File

@@ -32,6 +32,21 @@ use Illuminate\Support\Facades\Log;
*/
trait DepositValidation
{
/**
* @param array $accountTypes
*
* @return bool
*/
abstract protected function canCreateTypes(array $accountTypes): bool;
/**
* @param array $validTypes
* @param array $data
*
* @return Account|null
*/
abstract protected function findExistingAccount(array $validTypes, array $data): ?Account;
/**
* @param array $array
*
@@ -71,7 +86,7 @@ trait DepositValidation
if (null !== $search) {
Log::debug(sprintf('findExistingAccount() returned #%d ("%s"), so the result is true.', $search->id, $search->name));
$this->setDestination($search);
$result = true;
$result = true;
}
}
Log::debug(sprintf('validateDepositDestination will return %s', var_export($result, true)));
@@ -79,21 +94,6 @@ trait DepositValidation
return $result;
}
/**
* @param array $accountTypes
*
* @return bool
*/
abstract protected function canCreateTypes(array $accountTypes): bool;
/**
* @param array $validTypes
* @param array $data
*
* @return Account|null
*/
abstract protected function findExistingAccount(array $validTypes, array $data): ?Account;
/**
* @param array $array
*
@@ -132,7 +132,7 @@ trait DepositValidation
if (null !== $search && in_array($search->accountType->type, $validTypes, true)) {
Log::debug('ID result is not null and seems valid, save as source account.');
$this->setSource($search);
$result = true;
$result = true;
}
}
@@ -146,7 +146,7 @@ trait DepositValidation
if (null !== $search && in_array($search->accountType->type, $validTypes, true)) {
Log::debug('IBAN result is not null and seems valid, save as source account.');
$this->setSource($search);
$result = true;
$result = true;
}
}
@@ -162,7 +162,7 @@ trait DepositValidation
if (null !== $search && in_array($search->accountType->type, $validTypes, true)) {
Log::debug('Number result is not null and seems valid, save as source account.');
$this->setSource($search);
$result = true;
$result = true;
}
}

View File

@@ -33,6 +33,13 @@ use Illuminate\Support\Facades\Log;
*/
trait OBValidation
{
/**
* @param array $accountTypes
*
* @return bool
*/
abstract protected function canCreateTypes(array $accountTypes): bool;
/**
* @param array $array
*
@@ -71,7 +78,7 @@ trait OBValidation
if (null !== $search) {
Log::debug(sprintf('findExistingAccount() returned #%d ("%s"), so the result is true.', $search->id, $search->name));
$this->setDestination($search);
$result = true;
$result = true;
}
}
Log::debug(sprintf('validateOBDestination(%d, "%s") will return %s', $accountId, $accountName, var_export($result, true)));
@@ -79,13 +86,6 @@ trait OBValidation
return $result;
}
/**
* @param array $accountTypes
*
* @return bool
*/
abstract protected function canCreateTypes(array $accountTypes): bool;
/**
* Source of an opening balance can either be an asset account
* or an "initial balance account". The latter can be created.
@@ -128,7 +128,7 @@ trait OBValidation
if (null !== $search && in_array($search->accountType->type, $validTypes, true)) {
Log::debug(sprintf('Found account of correct type: #%d, "%s"', $search->id, $search->name));
$this->setSource($search);
$result = true;
$result = true;
}
}

View File

@@ -31,6 +31,21 @@ use Illuminate\Support\Facades\Log;
*/
trait TransferValidation
{
/**
* @param array $accountTypes
*
* @return bool
*/
abstract protected function canCreateTypes(array $accountTypes): bool;
/**
* @param array $validTypes
* @param array $data
*
* @return Account|null
*/
abstract protected function findExistingAccount(array $validTypes, array $data): ?Account;
/**
* @param array $array
*
@@ -72,21 +87,6 @@ trait TransferValidation
return true;
}
/**
* @param array $accountTypes
*
* @return bool
*/
abstract protected function canCreateTypes(array $accountTypes): bool;
/**
* @param array $validTypes
* @param array $data
*
* @return Account|null
*/
abstract protected function findExistingAccount(array $validTypes, array $data): ?Account;
/**
* @param array $array
*

View File

@@ -32,6 +32,21 @@ use Illuminate\Support\Facades\Log;
*/
trait WithdrawalValidation
{
/**
* @param array $accountTypes
*
* @return bool
*/
abstract protected function canCreateTypes(array $accountTypes): bool;
/**
* @param array $validTypes
* @param array $data
*
* @return Account|null
*/
abstract protected function findExistingAccount(array $validTypes, array $data): ?Account;
/**
* @param array $array
*
@@ -67,21 +82,6 @@ trait WithdrawalValidation
return true;
}
/**
* @param array $accountTypes
*
* @return bool
*/
abstract protected function canCreateTypes(array $accountTypes): bool;
/**
* @param array $validTypes
* @param array $data
*
* @return Account|null
*/
abstract protected function findExistingAccount(array $validTypes, array $data): ?Account;
/**
* @param array $array
*
@@ -128,10 +128,10 @@ trait WithdrawalValidation
*/
protected function validateWithdrawalSource(array $array): bool
{
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
$accountIban = array_key_exists('iban', $array) ? $array['iban'] : null;
$accountNumber =array_key_exists('number', $array) ? $array['number'] : null;
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
$accountIban = array_key_exists('iban', $array) ? $array['iban'] : null;
$accountNumber = array_key_exists('number', $array) ? $array['number'] : null;
Log::debug('Now in validateWithdrawalSource', $array);
// source can be any of the following types.