Various PSR12 code cleanup

This commit is contained in:
James Cole
2022-12-29 19:42:40 +01:00
parent 6cfdc58cb1
commit 56b9b66352
38 changed files with 763 additions and 691 deletions

View File

@@ -32,22 +32,7 @@ use 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
* @param array $array
*
* @return bool
*/
@@ -61,7 +46,7 @@ trait TransferValidation
if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL we return false,
// because the destination of a transfer can't be created.
$this->destError = (string) trans('validation.transfer_dest_need_data');
$this->destError = (string)trans('validation.transfer_dest_need_data');
Log::error('Both values are NULL, cant create transfer destination.');
return false;
@@ -70,7 +55,7 @@ trait TransferValidation
// or try to find the account:
$search = $this->findExistingAccount($validTypes, $array);
if (null === $search) {
$this->destError = (string) trans('validation.transfer_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
$this->destError = (string)trans('validation.transfer_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
return false;
}
@@ -88,7 +73,22 @@ trait TransferValidation
}
/**
* @param array $array
* @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
*
* @return bool
*/
@@ -102,7 +102,7 @@ trait TransferValidation
if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL we return false,
// because the source of a withdrawal can't be created.
$this->sourceError = (string) trans('validation.transfer_source_need_data');
$this->sourceError = (string)trans('validation.transfer_source_need_data');
app('log')->warning('Not a valid source, need more data.');
return false;
@@ -111,7 +111,7 @@ trait TransferValidation
// otherwise try to find the account:
$search = $this->findExistingAccount($validTypes, $array);
if (null === $search) {
$this->sourceError = (string) trans('validation.transfer_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
$this->sourceError = (string)trans('validation.transfer_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
app('log')->warning('Not a valid source, cant find it.', $validTypes);
return false;