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