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