mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-07 06:31:22 +00:00
Reformat various code.
This commit is contained in:
@@ -40,7 +40,7 @@ trait DepositValidation
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param array $validTypes
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account|null
|
||||
@@ -65,7 +65,7 @@ trait DepositValidation
|
||||
if (null === $accountId && null === $accountName && 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');
|
||||
Log::error('Both values are NULL, cant create deposit destination.');
|
||||
$result = false;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ trait DepositValidation
|
||||
$search = $this->findExistingAccount($validTypes, $array);
|
||||
if (null === $search) {
|
||||
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) {
|
||||
@@ -114,7 +114,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ trait LiabilityValidation
|
||||
$validTypes = config('firefly.valid_liabilities');
|
||||
|
||||
if (null === $accountId) {
|
||||
$this->sourceError = (string)trans('validation.lc_destination_need_data');
|
||||
$this->sourceError = (string) trans('validation.lc_destination_need_data');
|
||||
$result = false;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ trait LiabilityValidation
|
||||
protected function validateLCSource(array $array): bool
|
||||
{
|
||||
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
|
||||
$result = true;
|
||||
$result = true;
|
||||
Log::debug('Now in validateLCDestination', $array);
|
||||
if ('' === $accountName || null === $accountName) {
|
||||
$result = false;
|
||||
|
||||
@@ -57,7 +57,7 @@ trait OBValidation
|
||||
if (null === $accountId && null === $accountName && 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.ob_dest_need_data');
|
||||
$this->destError = (string) trans('validation.ob_dest_need_data');
|
||||
Log::error('Both values are NULL, cant create OB destination.');
|
||||
$result = false;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ trait OBValidation
|
||||
$search = $this->findExistingAccount($validTypes, $array);
|
||||
if (null === $search) {
|
||||
Log::debug('findExistingAccount() returned NULL, so the result is false.', $validTypes);
|
||||
$this->destError = (string)trans('validation.ob_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
$this->destError = (string) trans('validation.ob_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
$result = false;
|
||||
}
|
||||
if (null !== $search) {
|
||||
@@ -108,7 +108,7 @@ trait OBValidation
|
||||
// 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.ob_source_need_data');
|
||||
$this->sourceError = (string) trans('validation.ob_source_need_data');
|
||||
$result = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,9 @@ use Log;
|
||||
*/
|
||||
trait ReconciliationValidation
|
||||
{
|
||||
public ?Account $destination;
|
||||
public ?Account $source;
|
||||
public ?Account $destination;
|
||||
public ?Account $source;
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
*
|
||||
@@ -42,7 +43,7 @@ trait ReconciliationValidation
|
||||
*/
|
||||
protected function validateReconciliationDestination(array $array): bool
|
||||
{
|
||||
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
|
||||
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
|
||||
Log::debug('Now in validateReconciliationDestination', $array);
|
||||
if (null === $accountId) {
|
||||
Log::debug('Return FALSE');
|
||||
@@ -51,7 +52,7 @@ trait ReconciliationValidation
|
||||
}
|
||||
$result = $this->accountRepository->find($accountId);
|
||||
if (null === $result) {
|
||||
$this->destError = (string)trans('validation.deposit_dest_bad_data', ['id' => $accountId, 'name' => '']);
|
||||
$this->destError = (string) trans('validation.deposit_dest_bad_data', ['id' => $accountId, 'name' => '']);
|
||||
Log::debug('Return FALSE');
|
||||
|
||||
return false;
|
||||
@@ -76,7 +77,7 @@ trait ReconciliationValidation
|
||||
|
||||
return true;
|
||||
}
|
||||
$this->destError = (string)trans('validation.deposit_dest_wrong_type');
|
||||
$this->destError = (string) trans('validation.deposit_dest_wrong_type');
|
||||
Log::debug('Return FALSE');
|
||||
|
||||
return false;
|
||||
@@ -89,7 +90,7 @@ trait ReconciliationValidation
|
||||
*/
|
||||
protected function validateReconciliationSource(array $array): bool
|
||||
{
|
||||
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
|
||||
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
|
||||
Log::debug('In validateReconciliationSource', $array);
|
||||
if (null === $accountId) {
|
||||
Log::debug('Return FALSE');
|
||||
|
||||
@@ -39,7 +39,7 @@ trait TransferValidation
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param array $validTypes
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account|null
|
||||
@@ -61,16 +61,16 @@ 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;
|
||||
}
|
||||
|
||||
// or try to find the account:
|
||||
$search = $this->findExistingAccount($validTypes,$array);
|
||||
$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;
|
||||
}
|
||||
@@ -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');
|
||||
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]);
|
||||
Log::warning('Not a valid source, cant find it.', $validTypes);
|
||||
|
||||
return false;
|
||||
|
||||
@@ -40,7 +40,7 @@ trait WithdrawalValidation
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param array $validTypes
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account|null
|
||||
@@ -62,7 +62,7 @@ trait WithdrawalValidation
|
||||
if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {
|
||||
// if both values are NULL we return TRUE
|
||||
// because we assume the user doesnt want to submit / change anything.
|
||||
$this->sourceError = (string)trans('validation.withdrawal_source_need_data');
|
||||
$this->sourceError = (string) trans('validation.withdrawal_source_need_data');
|
||||
Log::warning('[a] Not a valid source. Need more data.');
|
||||
|
||||
return false;
|
||||
@@ -71,7 +71,7 @@ trait WithdrawalValidation
|
||||
// otherwise try to find the account:
|
||||
$search = $this->findExistingAccount($validTypes, $array);
|
||||
if (null === $search) {
|
||||
$this->sourceError = (string)trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
$this->sourceError = (string) trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
Log::warning('Not a valid source. Cant find it.', $validTypes);
|
||||
|
||||
return false;
|
||||
@@ -97,7 +97,7 @@ trait WithdrawalValidation
|
||||
if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {
|
||||
// if both values are NULL return false,
|
||||
// because the destination of a withdrawal can never be created automatically.
|
||||
$this->destError = (string)trans('validation.withdrawal_dest_need_data');
|
||||
$this->destError = (string) trans('validation.withdrawal_dest_need_data');
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ trait WithdrawalValidation
|
||||
if (in_array($type, $validTypes, true)) {
|
||||
return true;
|
||||
}
|
||||
$this->destError = (string)trans('validation.withdrawal_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
$this->destError = (string) trans('validation.withdrawal_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ trait WithdrawalValidation
|
||||
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.withdrawal_source_need_data');
|
||||
$this->sourceError = (string) trans('validation.withdrawal_source_need_data');
|
||||
Log::warning('[b] Not a valid source. Need more data.');
|
||||
|
||||
return false;
|
||||
@@ -145,7 +145,7 @@ trait WithdrawalValidation
|
||||
// otherwise try to find the account:
|
||||
$search = $this->findExistingAccount($validTypes, $array);
|
||||
if (null === $search) {
|
||||
$this->sourceError = (string)trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
$this->sourceError = (string) trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
Log::warning('Not a valid source. Cant find it.', $validTypes);
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user