mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 08:35:00 +00:00
Refactor phpstan errors.
This commit is contained in:
@@ -24,46 +24,36 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Rules;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
/**
|
||||
* Class IsBoolean
|
||||
*/
|
||||
class IsBoolean implements Rule
|
||||
class IsBoolean implements ValidationRule
|
||||
{
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message(): string
|
||||
{
|
||||
return (string)trans('validation.boolean');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @param Closure $fail
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return bool
|
||||
* @return void
|
||||
*/
|
||||
public function passes($attribute, $value): bool
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
if (is_int($value) && 0 === $value) {
|
||||
return true;
|
||||
if (0 === $value) {
|
||||
return;
|
||||
}
|
||||
if (is_int($value) && 1 === $value) {
|
||||
return true;
|
||||
if (1 === $value) {
|
||||
return;
|
||||
}
|
||||
if (is_string($value) && in_array($value, ['0', '1', 'true', 'false', 'on', 'off', 'yes', 'no', 'y', 'n'], true)) {
|
||||
return true;
|
||||
if (in_array($value, ['0', '1', 'true', 'false', 'on', 'off', 'yes', 'no', 'y', 'n'], true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return false;
|
||||
$fail('validation.boolean')->translate();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user