mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Use PSR-12 code style
This commit is contained in:
@@ -31,5 +31,4 @@ namespace FireflyIII\Validation\Account;
|
||||
*/
|
||||
trait AccountValidatorProperties
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -153,7 +153,7 @@ trait DepositValidation
|
||||
$result = true;
|
||||
|
||||
// set the source to be a (dummy) revenue account.
|
||||
$account = new Account;
|
||||
$account = new Account();
|
||||
$accountType = AccountType::whereType(AccountType::REVENUE)->first();
|
||||
$account->accountType = $accountType;
|
||||
$this->source = $account;
|
||||
|
@@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Validation\Account;
|
||||
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use Log;
|
||||
@@ -34,7 +33,6 @@ use Log;
|
||||
*/
|
||||
trait LiabilityValidation
|
||||
{
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
*
|
||||
@@ -89,7 +87,7 @@ trait LiabilityValidation
|
||||
}
|
||||
if (true === $result) {
|
||||
// set the source to be a (dummy) revenue account.
|
||||
$account = new Account;
|
||||
$account = new Account();
|
||||
$accountType = AccountType::whereType(AccountType::LIABILITY_CREDIT)->first();
|
||||
$account->accountType = $accountType;
|
||||
$this->source = $account;
|
||||
@@ -97,5 +95,4 @@ trait LiabilityValidation
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -139,7 +139,7 @@ trait OBValidation
|
||||
$result = true;
|
||||
|
||||
// set the source to be a (dummy) initial balance account.
|
||||
$account = new Account;
|
||||
$account = new Account();
|
||||
$accountType = AccountType::whereType(AccountType::INITIAL_BALANCE)->first();
|
||||
$account->accountType = $accountType;
|
||||
$this->source = $account;
|
||||
|
@@ -86,7 +86,7 @@ trait ReconciliationValidation
|
||||
// source to the asset account that is the destination.
|
||||
if (null === $accountId && null === $accountName) {
|
||||
Log::debug('The source is valid because ID and name are NULL.');
|
||||
$this->source = new Account;
|
||||
$this->source = new Account();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -107,5 +107,4 @@ trait ReconciliationValidation
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -42,7 +42,13 @@ use Log;
|
||||
*/
|
||||
class AccountValidator
|
||||
{
|
||||
use AccountValidatorProperties, WithdrawalValidation, DepositValidation, TransferValidation, ReconciliationValidation, OBValidation, LiabilityValidation;
|
||||
use AccountValidatorProperties;
|
||||
use WithdrawalValidation;
|
||||
use DepositValidation;
|
||||
use TransferValidation;
|
||||
use ReconciliationValidation;
|
||||
use OBValidation;
|
||||
use LiabilityValidation;
|
||||
|
||||
public bool $createMode;
|
||||
public string $destError;
|
||||
@@ -258,5 +264,4 @@ class AccountValidator
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -73,5 +73,4 @@ trait ValidatesBulkTransactionQuery
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ trait ValidatesAutoBudgetRequest
|
||||
$validator->errors()->add('auto_budget_amount', (string) trans('validation.require_currency_info'));
|
||||
}
|
||||
// too big amount
|
||||
if((int)$amount > 268435456) {
|
||||
if ((int)$amount > 268435456) {
|
||||
$validator->errors()->add('auto_budget_amount', (string) trans('validation.amount_required_for_auto_budget'));
|
||||
return;
|
||||
}
|
||||
|
@@ -49,7 +49,8 @@ trait CurrencyValidation
|
||||
if (array_key_exists('foreign_amount', $transaction)
|
||||
&& !(array_key_exists('foreign_currency_id', $transaction)
|
||||
|| array_key_exists(
|
||||
'foreign_currency_code', $transaction
|
||||
'foreign_currency_code',
|
||||
$transaction
|
||||
))
|
||||
&& 0 !== bccomp('0', $transaction['foreign_amount'])
|
||||
) {
|
||||
@@ -61,7 +62,8 @@ trait CurrencyValidation
|
||||
// if the currency is present, then the amount must be present as well.
|
||||
if ((array_key_exists('foreign_currency_id', $transaction) || array_key_exists('foreign_currency_code', $transaction))
|
||||
&& !array_key_exists(
|
||||
'foreign_amount', $transaction
|
||||
'foreign_amount',
|
||||
$transaction
|
||||
)) {
|
||||
$validator->errors()->add(
|
||||
'transactions.' . $index . '.foreign_amount',
|
||||
|
@@ -47,6 +47,7 @@ use PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException;
|
||||
use PragmaRX\Google2FA\Exceptions\InvalidCharactersException;
|
||||
use PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException;
|
||||
use ValueError;
|
||||
|
||||
use function is_string;
|
||||
|
||||
/**
|
||||
@@ -54,7 +55,6 @@ use function is_string;
|
||||
*/
|
||||
class FireflyValidator extends Validator
|
||||
{
|
||||
|
||||
/**
|
||||
* @param mixed $attribute
|
||||
* @param mixed $value
|
||||
@@ -364,7 +364,7 @@ class FireflyValidator extends Validator
|
||||
}
|
||||
|
||||
// check if it's an existing account.
|
||||
if (in_array($triggerType, ['destination_account_id', 'source_account_id'])) {
|
||||
if (in_array($triggerType, ['destination_account_id', 'source_account_id'], true)) {
|
||||
return is_numeric($value) && (int) $value > 0;
|
||||
}
|
||||
|
||||
@@ -382,7 +382,6 @@ class FireflyValidator extends Validator
|
||||
try {
|
||||
$parser->parseDate($value);
|
||||
} catch (FireflyException $e) {
|
||||
|
||||
Log::error($e->getMessage());
|
||||
|
||||
return false;
|
||||
@@ -390,7 +389,6 @@ class FireflyValidator extends Validator
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -424,7 +422,6 @@ class FireflyValidator extends Validator
|
||||
*/
|
||||
public function validateUniqueAccountForUser($attribute, $value, $parameters): bool
|
||||
{
|
||||
|
||||
// because a user does not have to be logged in (tests and what-not).
|
||||
if (!auth()->check()) {
|
||||
return $this->validateAccountAnonymously();
|
||||
@@ -501,7 +498,6 @@ class FireflyValidator extends Validator
|
||||
);
|
||||
|
||||
return null === $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -812,7 +808,6 @@ class FireflyValidator extends Validator
|
||||
public function validateUniqueWebhook($value, $parameters): bool
|
||||
{
|
||||
if (auth()->check()) {
|
||||
|
||||
$triggers = Webhook::getTriggersForValidation();
|
||||
$responses = Webhook::getResponsesForValidation();
|
||||
$deliveries = Webhook::getDeliveriesForValidation();
|
||||
|
@@ -35,7 +35,6 @@ use Log;
|
||||
*/
|
||||
trait GroupValidation
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Validator $validator
|
||||
*
|
||||
@@ -62,10 +61,12 @@ trait GroupValidation
|
||||
// set errors:
|
||||
if (false === $hasAccountInfo && !$hasJournalId) {
|
||||
$validator->errors()->add(
|
||||
sprintf('transactions.%d.source_id', $index), (string) trans('validation.generic_no_source')
|
||||
sprintf('transactions.%d.source_id', $index),
|
||||
(string) trans('validation.generic_no_source')
|
||||
);
|
||||
$validator->errors()->add(
|
||||
sprintf('transactions.%d.destination_id', $index), (string) trans('validation.generic_no_destination')
|
||||
sprintf('transactions.%d.destination_id', $index),
|
||||
(string) trans('validation.generic_no_destination')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -93,7 +94,8 @@ trait GroupValidation
|
||||
// no valid descriptions?
|
||||
if (0 === $validDescriptions) {
|
||||
$validator->errors()->add(
|
||||
'transactions.0.description', (string) trans('validation.filled', ['attribute' => (string) trans('validation.attributes.description')])
|
||||
'transactions.0.description',
|
||||
(string) trans('validation.filled', ['attribute' => (string) trans('validation.attributes.description')])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user