Conditions | 5 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
28 | public function check($value): bool |
||
29 | { |
||
30 | if (! is_string($value)) { |
||
31 | 2 | return false; |
|
32 | } |
||
33 | |||
34 | 4 | $this->requireParameters(['length']); |
|
35 | |||
36 | 4 | $length = (int) $this->parameter('length'); |
|
37 | 4 | $separator = $this->parameter('separator'); |
|
38 | |||
39 | 4 | $texts = explode($separator ?: '-', $value); |
|
40 | |||
41 | foreach ($texts as $text) { |
||
42 | if (strlen($text) !== $length) { |
||
43 | 4 | return false; |
|
44 | } |
||
45 | } |
||
46 | |||
47 | 4 | return true; |
|
48 | } |
||
50 |