make static-analyse code

This commit is contained in:
2024-01-15 01:05:10 +03:00
parent 57244b63be
commit bc2c8df9af
35 changed files with 221 additions and 182 deletions

View File

@@ -6,21 +6,21 @@ use Illuminate\Contracts\Validation\Rule;
class MinWords implements Rule
{
protected $minWords;
protected int $minWords;
public function __construct($minWords)
public function __construct(int $minWords)
{
$this->minWords = $minWords;
}
public function passes($attribute, $value)
public function passes(mixed $attribute, mixed $value): bool|int
{
$wordCount = count(preg_split('/\W+/u', $value, -1, PREG_SPLIT_NO_EMPTY));
return $wordCount >= $this->minWords;
}
public function message()
public function message(): string
{
return "The :attribute must have at least {$this->minWords} words.";
}