chore: reformat code.

This commit is contained in:
James Cole
2023-06-21 12:34:58 +02:00
parent 8d87abde64
commit 3dcb35710b
799 changed files with 23319 additions and 22173 deletions

View File

@@ -33,22 +33,7 @@ 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
* @param array $array
*
* @return bool
*/
@@ -96,7 +81,22 @@ trait DepositValidation
}
/**
* @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
*/

View File

@@ -34,7 +34,7 @@ use Illuminate\Support\Facades\Log;
trait LiabilityValidation
{
/**
* @param array $array
* @param array $array
*
* @return bool
*/
@@ -72,7 +72,7 @@ trait LiabilityValidation
/**
* Source of a liability credit must be a liability or liability credit account.
*
* @param array $array
* @param array $array
*
* @return bool
*/

View File

@@ -34,14 +34,7 @@ use Illuminate\Support\Facades\Log;
trait OBValidation
{
/**
* @param array $accountTypes
*
* @return bool
*/
abstract protected function canCreateTypes(array $accountTypes): bool;
/**
* @param array $array
* @param array $array
*
* @return bool
*/
@@ -86,11 +79,18 @@ 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.
*
* @param array $array
* @param array $array
*
* @return bool
*/

View File

@@ -36,7 +36,7 @@ trait ReconciliationValidation
public ?Account $source;
/**
* @param array $array
* @param array $array
*
* @return bool
*/
@@ -72,7 +72,8 @@ trait ReconciliationValidation
/**
* Basically the same check
* @param array $array
*
* @param array $array
*
* @return bool
*/

View File

@@ -32,22 +32,7 @@ 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
* @param array $array
*
* @return bool
*/
@@ -89,7 +74,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
*/

View File

@@ -33,22 +33,7 @@ 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
* @param array $array
*
* @return bool
*/
@@ -84,7 +69,22 @@ trait WithdrawalValidation
}
/**
* @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
*/
@@ -123,7 +123,7 @@ trait WithdrawalValidation
}
/**
* @param array $array
* @param array $array
*
* @return bool
*/

View File

@@ -83,7 +83,7 @@ class AccountValidator
}
/**
* @param Account|null $account
* @param Account|null $account
*/
public function setSource(?Account $account): void
{
@@ -97,7 +97,7 @@ class AccountValidator
}
/**
* @param Account|null $account
* @param Account|null $account
*/
public function setDestination(?Account $account): void
{
@@ -111,7 +111,7 @@ class AccountValidator
}
/**
* @param string $transactionType
* @param string $transactionType
*/
public function setTransactionType(string $transactionType): void
{
@@ -120,7 +120,7 @@ class AccountValidator
}
/**
* @param User $user
* @param User $user
*/
public function setUser(User $user): void
{
@@ -129,7 +129,7 @@ class AccountValidator
}
/**
* @param array $array
* @param array $array
*
* @return bool
*/
@@ -174,7 +174,7 @@ class AccountValidator
}
/**
* @param array $array
* @param array $array
*
* @return bool
*/
@@ -212,22 +212,7 @@ class AccountValidator
}
/**
* @param string $accountType
*
* @return bool
*/
protected function canCreateType(string $accountType): bool
{
$canCreate = [AccountType::EXPENSE, AccountType::REVENUE, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT];
if (in_array($accountType, $canCreate, true)) {
return true;
}
return false;
}
/**
* @param array $accountTypes
* @param array $accountTypes
*
* @return bool
*/
@@ -248,8 +233,23 @@ class AccountValidator
}
/**
* @param array $validTypes
* @param array $data
* @param string $accountType
*
* @return bool
*/
protected function canCreateType(string $accountType): bool
{
$canCreate = [AccountType::EXPENSE, AccountType::REVENUE, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT];
if (in_array($accountType, $canCreate, true)) {
return true;
}
return false;
}
/**
* @param array $validTypes
* @param array $data
*
* @return Account|null
*/

View File

@@ -37,8 +37,8 @@ use Illuminate\Validation\Validator;
trait ValidatesAdministrationAccess
{
/**
* @param Validator $validator
* @param array $allowedRoles
* @param Validator $validator
* @param array $allowedRoles
* @return void
* @throws AuthenticationException
* @throws FireflyException

View File

@@ -34,7 +34,7 @@ use JsonException;
trait ValidatesBulkTransactionQuery
{
/**
* @param Validator $validator
* @param Validator $validator
*
* @throws JsonException
*/

View File

@@ -31,7 +31,7 @@ use Illuminate\Validation\Validator;
trait ValidatesAutoBudgetRequest
{
/**
* @param Validator $validator
* @param Validator $validator
*/
protected function validateAutoBudgetAmount(Validator $validator): void
{

View File

@@ -36,17 +36,10 @@ trait CurrencyValidation
{
public const TEST = 'Test';
/**
* @param Validator $validator
*
* @return array
*/
abstract protected function getTransactionsArray(Validator $validator): array;
/**
* If the transactions contain foreign amounts, there must also be foreign currency information.
*
* @param Validator $validator
* @param Validator $validator
*/
protected function validateForeignCurrencyInformation(Validator $validator): void
{
@@ -70,7 +63,7 @@ trait CurrencyValidation
&& 0 !== bccomp('0', $transaction['foreign_amount'])
) {
$validator->errors()->add(
'transactions.'.$index.'.foreign_amount',
'transactions.' . $index . '.foreign_amount',
(string)trans('validation.require_currency_info')
);
}
@@ -81,10 +74,17 @@ trait CurrencyValidation
$transaction
)) {
$validator->errors()->add(
'transactions.'.$index.'.foreign_amount',
'transactions.' . $index . '.foreign_amount',
(string)trans('validation.require_currency_amount')
);
}
}
}
/**
* @param Validator $validator
*
* @return array
*/
abstract protected function getTransactionsArray(Validator $validator): array;
}

View File

@@ -56,8 +56,8 @@ use function is_string;
class FireflyValidator extends Validator
{
/**
* @param mixed $attribute
* @param mixed $value
* @param mixed $attribute
* @param mixed $value
*
* @return bool
* @throws IncompatibleWithGoogleAuthenticatorException
@@ -81,9 +81,9 @@ class FireflyValidator extends Validator
}
/**
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
*
* @return bool
*/
@@ -100,8 +100,8 @@ class FireflyValidator extends Validator
}
/**
* @param mixed $attribute
* @param mixed $value
* @param mixed $attribute
* @param mixed $value
*
* @return bool
*/
@@ -120,8 +120,8 @@ class FireflyValidator extends Validator
}
/**
* @param mixed $attribute
* @param mixed $value
* @param mixed $attribute
* @param mixed $value
*
* @return bool
*/
@@ -221,7 +221,7 @@ class FireflyValidator extends Validator
// take
$first = substr($value, 0, 4);
$last = substr($value, 4);
$iban = $last.$first;
$iban = $last . $first;
$iban = trim(str_replace($search, $replace, $iban));
if (0 === strlen($iban)) {
return false;
@@ -240,9 +240,9 @@ class FireflyValidator extends Validator
}
/**
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
*
* @return bool
*/
@@ -255,9 +255,9 @@ class FireflyValidator extends Validator
}
/**
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
*
* @return bool
*/
@@ -270,9 +270,9 @@ class FireflyValidator extends Validator
}
/**
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
*
* @return bool
*/
@@ -289,9 +289,9 @@ class FireflyValidator extends Validator
}
/**
* @param string $attribute
* @param string $attribute
*
* @param string|null $value
* @param string|null $value
*
* @return bool
*/
@@ -361,8 +361,8 @@ class FireflyValidator extends Validator
/**
* $attribute has the format triggers.%d.value.
*
* @param string $attribute
* @param string|null $value
* @param string $attribute
* @param string|null $value
*
* @return bool
*/
@@ -442,8 +442,8 @@ class FireflyValidator extends Validator
}
/**
* @param mixed $attribute
* @param mixed $value
* @param mixed $attribute
* @param mixed $value
*
* @return bool
*/
@@ -464,9 +464,9 @@ class FireflyValidator extends Validator
}
/**
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
*
* @return bool
*/
@@ -505,9 +505,124 @@ class FireflyValidator extends Validator
}
/**
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
* @return bool
*/
private function validateAccountAnonymously(): bool
{
if (!array_key_exists('user_id', $this->data)) {
return false;
}
$user = User::find($this->data['user_id']);
$type = AccountType::find($this->data['account_type_id'])->first();
$value = $this->data['name'];
/** @var Account|null $result */
$result = $user->accounts()->where('account_type_id', $type->id)->where('name', $value)->first();
return null === $result;
}
/**
* @param string $value
* @param array $parameters
* @param string $type
*
* @return bool
*/
private function validateByAccountTypeString(string $value, array $parameters, string $type): bool
{
/** @var array|null $search */
$search = Config::get('firefly.accountTypeByIdentifier.' . $type);
if (null === $search) {
return false;
}
$accountTypes = AccountType::whereIn('type', $search)->get();
$ignore = (int)($parameters[0] ?? 0.0);
$accountTypeIds = $accountTypes->pluck('id')->toArray();
/** @var Account|null $result */
$result = auth()->user()->accounts()->whereIn('account_type_id', $accountTypeIds)->where('id', '!=', $ignore)
->where('name', $value)
->first();
return null === $result;
}
/**
* @param mixed $value
* @param mixed $parameters
*
* @return bool
*/
private function validateByAccountTypeId($value, $parameters): bool
{
$type = AccountType::find($this->data['account_type_id'])->first();
$ignore = (int)($parameters[0] ?? 0.0);
/** @var Account|null $result */
$result = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
->where('name', $value)
->first();
return null === $result;
}
/**
* @param int $accountId
* @param mixed $value
*
* @return bool
*/
private function validateByParameterId(int $accountId, $value): bool
{
/** @var Account $existingAccount */
$existingAccount = Account::find($accountId);
$type = $existingAccount->accountType;
$ignore = $existingAccount->id;
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
->where('name', $value)
->first();
return null === $entry;
}
/**
* @param mixed $value
*
* @return bool
*/
private function validateByAccountId($value): bool
{
/** @var Account $existingAccount */
$existingAccount = Account::find($this->data['id']);
$type = $existingAccount->accountType;
$ignore = $existingAccount->id;
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
->where('name', $value)
->first();
return null === $entry;
}
/**
* @param string $value
*
* @return bool
*/
private function validateByAccountName(string $value): bool
{
return auth()->user()->accounts()->where('name', $value)->count() === 0;
}
/**
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
*
* @return bool
*/
@@ -557,17 +672,6 @@ class FireflyValidator extends Validator
return false;
}
/**
* @param string $field
* @param string $attribute
* @param string $value
* @return bool
*/
public function validateUniqueCurrency(string $field, string $attribute, string $value): bool
{
return 0 === DB::table('transaction_currencies')->where($field, $value)->whereNull('deleted_at')->count();
}
/**
* @param $attribute
* @param $value
@@ -578,6 +682,17 @@ class FireflyValidator extends Validator
return $this->validateUniqueCurrency('code', (string)$attribute, (string)$value);
}
/**
* @param string $field
* @param string $attribute
* @param string $value
* @return bool
*/
public function validateUniqueCurrency(string $field, string $attribute, string $value): bool
{
return 0 === DB::table('transaction_currencies')->where($field, $value)->whereNull('deleted_at')->count();
}
/**
* @param $attribute
* @param $value
@@ -599,9 +714,9 @@ class FireflyValidator extends Validator
}
/**
* @param mixed $value
* @param mixed $parameters
* @param mixed $something
* @param mixed $value
* @param mixed $parameters
* @param mixed $something
*
* @return bool
*/
@@ -654,9 +769,9 @@ class FireflyValidator extends Validator
* parameter 1: the field
* parameter 2: an id to ignore (when editing)
*
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
*
* @return bool
*/
@@ -686,9 +801,9 @@ class FireflyValidator extends Validator
}
/**
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
*
* @return bool
*/
@@ -707,9 +822,9 @@ class FireflyValidator extends Validator
}
/**
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
* @param mixed $attribute
* @param mixed $value
* @param mixed $parameters
*
* @return bool
*/
@@ -727,8 +842,8 @@ class FireflyValidator extends Validator
}
/**
* @param mixed $value
* @param mixed $parameters
* @param mixed $value
* @param mixed $parameters
*
* @return bool
*/
@@ -755,119 +870,4 @@ class FireflyValidator extends Validator
return false;
}
/**
* @return bool
*/
private function validateAccountAnonymously(): bool
{
if (!array_key_exists('user_id', $this->data)) {
return false;
}
$user = User::find($this->data['user_id']);
$type = AccountType::find($this->data['account_type_id'])->first();
$value = $this->data['name'];
/** @var Account|null $result */
$result = $user->accounts()->where('account_type_id', $type->id)->where('name', $value)->first();
return null === $result;
}
/**
* @param mixed $value
*
* @return bool
*/
private function validateByAccountId($value): bool
{
/** @var Account $existingAccount */
$existingAccount = Account::find($this->data['id']);
$type = $existingAccount->accountType;
$ignore = $existingAccount->id;
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
->where('name', $value)
->first();
return null === $entry;
}
/**
* @param string $value
*
* @return bool
*/
private function validateByAccountName(string $value): bool
{
return auth()->user()->accounts()->where('name', $value)->count() === 0;
}
/**
* @param mixed $value
* @param mixed $parameters
*
* @return bool
*/
private function validateByAccountTypeId($value, $parameters): bool
{
$type = AccountType::find($this->data['account_type_id'])->first();
$ignore = (int)($parameters[0] ?? 0.0);
/** @var Account|null $result */
$result = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
->where('name', $value)
->first();
return null === $result;
}
/**
* @param string $value
* @param array $parameters
* @param string $type
*
* @return bool
*/
private function validateByAccountTypeString(string $value, array $parameters, string $type): bool
{
/** @var array|null $search */
$search = Config::get('firefly.accountTypeByIdentifier.'.$type);
if (null === $search) {
return false;
}
$accountTypes = AccountType::whereIn('type', $search)->get();
$ignore = (int)($parameters[0] ?? 0.0);
$accountTypeIds = $accountTypes->pluck('id')->toArray();
/** @var Account|null $result */
$result = auth()->user()->accounts()->whereIn('account_type_id', $accountTypeIds)->where('id', '!=', $ignore)
->where('name', $value)
->first();
return null === $result;
}
/**
* @param int $accountId
* @param mixed $value
*
* @return bool
*/
private function validateByParameterId(int $accountId, $value): bool
{
/** @var Account $existingAccount */
$existingAccount = Account::find($accountId);
$type = $existingAccount->accountType;
$ignore = $existingAccount->id;
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
->where('name', $value)
->first();
return null === $entry;
}
}

View File

@@ -37,14 +37,7 @@ use Illuminate\Validation\Validator;
trait GroupValidation
{
/**
* @param Validator $validator
*
* @return array
*/
abstract protected function getTransactionsArray(Validator $validator): array;
/**
* @param Validator $validator
* @param Validator $validator
*/
protected function preventNoAccountInfo(Validator $validator): void
{
@@ -86,11 +79,18 @@ trait GroupValidation
// only an issue if there is no transaction_journal_id
}
/**
* @param Validator $validator
*
* @return array
*/
abstract protected function getTransactionsArray(Validator $validator): array;
/**
* Adds an error to the "description" field when the user has submitted no descriptions and no
* journal description.
*
* @param Validator $validator
* @param Validator $validator
*/
protected function validateDescriptions(Validator $validator): void
{
@@ -116,7 +116,7 @@ trait GroupValidation
}
/**
* @param Validator $validator
* @param Validator $validator
*/
protected function validateGroupDescription(Validator $validator): void
{
@@ -134,11 +134,12 @@ trait GroupValidation
}
/**
* This method validates if the user has submitted transaction journal ID's for each array they submit, if they've submitted more than 1 transaction
* journal. This check is necessary because Firefly III isn't able to distinguish between journals without the ID.
* This method validates if the user has submitted transaction journal ID's for each array they submit, if they've
* submitted more than 1 transaction journal. This check is necessary because Firefly III isn't able to distinguish
* between journals without the ID.
*
* @param Validator $validator
* @param TransactionGroup $transactionGroup
* @param Validator $validator
* @param TransactionGroup $transactionGroup
*/
protected function validateJournalIds(Validator $validator, TransactionGroup $transactionGroup): void
{
@@ -153,7 +154,7 @@ trait GroupValidation
}
// check each array:
/**
* @var int $index
* @var int $index
* @var array $transaction
*/
foreach ($transactions as $index => $transaction) {
@@ -164,10 +165,10 @@ trait GroupValidation
/**
* Do the validation required by validateJournalIds.
*
* @param Validator $validator
* @param int $index
* @param array $transaction
* @param TransactionGroup $transactionGroup
* @param Validator $validator
* @param int $index
* @param array $transaction
* @param TransactionGroup $transactionGroup
*
*/
private function validateJournalId(Validator $validator, int $index, array $transaction, TransactionGroup $transactionGroup): void

View File

@@ -43,7 +43,7 @@ trait RecurrenceValidation
*
* TODO Must always trigger when the type of the recurrence changes.
*
* @param Validator $validator
* @param Validator $validator
*/
public function valUpdateAccountInfo(Validator $validator): void
{
@@ -119,7 +119,7 @@ trait RecurrenceValidation
/**
* Adds an error to the validator when there are no repetitions in the array of data.
*
* @param Validator $validator
* @param Validator $validator
*/
public function validateOneRepetition(Validator $validator): void
{
@@ -134,7 +134,7 @@ trait RecurrenceValidation
/**
* Adds an error to the validator when there are no repetitions in the array of data.
*
* @param Validator $validator
* @param Validator $validator
*/
public function validateOneRepetitionUpdate(Validator $validator): void
{
@@ -153,7 +153,7 @@ trait RecurrenceValidation
* Validates that the recurrence has valid repetition information. It either doesn't stop,
* or stops after X times or at X date. Not both of them.,
*
* @param Validator $validator
* @param Validator $validator
*/
public function validateRecurrenceRepetition(Validator $validator): void
{
@@ -186,7 +186,7 @@ trait RecurrenceValidation
}
/**
* @param Validator $validator
* @param Validator $validator
*/
public function validateRepetitionMoment(Validator $validator): void
{
@@ -198,7 +198,7 @@ trait RecurrenceValidation
return;
}
/**
* @var int $index
* @var int $index
* @var array $repetition
*/
foreach ($repetitions as $index => $repetition) {
@@ -237,9 +237,9 @@ trait RecurrenceValidation
/**
* If the repetition type is daily, the moment should be empty.
*
* @param Validator $validator
* @param int $index
* @param string $moment
* @param Validator $validator
* @param int $index
* @param string $moment
*/
protected function validateDaily(Validator $validator, int $index, string $moment): void
{
@@ -251,9 +251,9 @@ trait RecurrenceValidation
/**
* If the repetition type is monthly, the moment should be a day between 1-31 (inclusive).
*
* @param Validator $validator
* @param int $index
* @param int $dayOfMonth
* @param Validator $validator
* @param int $index
* @param int $dayOfMonth
*/
protected function validateMonthly(Validator $validator, int $index, int $dayOfMonth): void
{
@@ -266,9 +266,9 @@ trait RecurrenceValidation
* If the repetition type is "ndom", the first part must be between 1-5 (inclusive), for the week in the month,
* and the second one must be between 1-7 (inclusive) for the day of the week.
*
* @param Validator $validator
* @param int $index
* @param string $moment
* @param Validator $validator
* @param int $index
* @param string $moment
*/
protected function validateNdom(Validator $validator, int $index, string $moment): void
{
@@ -291,7 +291,38 @@ trait RecurrenceValidation
}
/**
* @param Validator $validator
* If the repetition type is weekly, the moment should be a day between 1-7 (inclusive).
*
* @param Validator $validator
* @param int $index
* @param int $dayOfWeek
*/
protected function validateWeekly(Validator $validator, int $index, int $dayOfWeek): void
{
if ($dayOfWeek < 1 || $dayOfWeek > 7) {
$validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
}
}
/**
* If the repetition type is yearly, the moment should be a valid date.
*
* @param Validator $validator
* @param int $index
* @param string $moment
*/
protected function validateYearly(Validator $validator, int $index, string $moment): void
{
try {
Carbon::createFromFormat('Y-m-d', $moment);
} catch (InvalidArgumentException $e) {
Log::debug(sprintf('Invalid argument for Carbon: %s', $e->getMessage()));
$validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
}
}
/**
* @param Validator $validator
* @return void
*/
protected function validateTransactionId(Recurrence $recurrence, Validator $validator): void
@@ -387,36 +418,4 @@ trait RecurrenceValidation
}
Log::debug('Done with ID validation.');
}
/**
* If the repetition type is weekly, the moment should be a day between 1-7 (inclusive).
*
* @param Validator $validator
* @param int $index
* @param int $dayOfWeek
*/
protected function validateWeekly(Validator $validator, int $index, int $dayOfWeek): void
{
if ($dayOfWeek < 1 || $dayOfWeek > 7) {
$validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
}
}
/**
* If the repetition type is yearly, the moment should be a valid date.
*
* @param Validator $validator
* @param int $index
* @param string $moment
*/
protected function validateYearly(Validator $validator, int $index, string $moment): void
{
try {
Carbon::createFromFormat('Y-m-d', $moment);
} catch (InvalidArgumentException $e) {
Log::debug(sprintf('Invalid argument for Carbon: %s', $e->getMessage()));
$validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
}
}
}

File diff suppressed because it is too large Load Diff