ValidDuplicateCharacter::message()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Milwad\LaravelValidate\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
7
class ValidDuplicateCharacter implements Rule
8
{
9
    /**
10
     * Check duplicate characters, splitted by comma.
11
     */
12
    public function passes($attribute, $value): bool
13
    {
14
        $value = explode(',', $value);
15
16
        return collect($value)->duplicates()->isEmpty();
0 ignored issues
show
Bug introduced by
$value of type string[] is incompatible with the type Illuminate\Contracts\Support\Arrayable expected by parameter $value of collect(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

16
        return collect(/** @scrutinizer ignore-type */ $value)->duplicates()->isEmpty();
Loading history...
17
    }
18
19
    /**
20
     * Get the validation error message.
21
     */
22
    public function message(): string
23
    {
24
        return __('validate.duplicate_character');
25
    }
26
}
27