| Conditions | 6 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | 13 | public function validate(mixed $value, object $rule, ValidatorInterface $validator, ?ValidationContext $context = null): Result |
|
| 21 | { |
||
| 22 | 13 | $result = new Result(); |
|
| 23 | |||
| 24 | 13 | if (!is_string($value)) { |
|
| 25 | 7 | $result->addError($rule->incorrectInputMessage); |
|
| 26 | |||
| 27 | 7 | return $result; |
|
| 28 | } |
||
| 29 | |||
| 30 | if ( |
||
| 31 | 6 | (!$rule->not && !preg_match($rule->pattern, $value)) || |
|
| 32 | 6 | ($rule->not && preg_match($rule->pattern, $value)) |
|
| 33 | ) { |
||
| 34 | 3 | $result->addError($rule->message); |
|
| 35 | } |
||
| 36 | |||
| 37 | 6 | return $result; |
|
| 38 | } |
||
| 40 |