mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Refactor phpstan errors.
This commit is contained in:
@@ -23,15 +23,16 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Rules;
|
||||
|
||||
use Closure;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountMeta;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
/**
|
||||
* Class UniqueAccountNumber
|
||||
*/
|
||||
class UniqueAccountNumber implements Rule
|
||||
class UniqueAccountNumber implements ValidationRule
|
||||
{
|
||||
private ?Account $account;
|
||||
private ?string $expectedType;
|
||||
@@ -73,21 +74,19 @@ class UniqueAccountNumber implements Rule
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return bool
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @param Closure $fail
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function passes($attribute, $value): bool
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if (!auth()->check()) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
if (null === $this->expectedType) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
$maxCounts = $this->getMaxOccurrences();
|
||||
|
||||
@@ -105,12 +104,11 @@ class UniqueAccountNumber implements Rule
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
$fail('validation.unique_account_number_for_user')->translate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
app('log')->debug('Account number is valid.');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user