| Conditions | 4 | 
| Paths | 3 | 
| Total Lines | 17 | 
| Code Lines | 9 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 10 | 
| CRAP Score | 4 | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 30 | 22 | public function validate(mixed $value, object $rule, ?ValidationContext $context = null): Result | |
| 31 |     { | ||
| 32 | 22 |         if (!$rule instanceof Required) { | |
| 33 | 1 | throw new UnexpectedRuleException(Required::class, $rule); | |
| 34 | } | ||
| 35 | |||
| 36 | 21 | $result = new Result(); | |
| 37 | |||
| 38 | 21 |         if ($this->isEmpty(is_string($value) ? trim($value) : $value)) { | |
| 39 | 6 | $formattedMessage = $this->formatter->format( | |
| 40 | 6 | $rule->getMessage(), | |
| 41 | 6 | ['attribute' => $context?->getAttribute(), 'value' => $value] | |
| 42 | ); | ||
| 43 | 6 | $result->addError($formattedMessage); | |
| 44 | } | ||
| 45 | |||
| 46 | 21 | return $result; | |
| 47 | } | ||
| 49 |