| Conditions | 4 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | 20 | public function validate(mixed $value, object $rule, ValidatorInterface $validator, ?ValidationContext $context = null): Result |
|
| 23 | { |
||
| 24 | 20 | if (!$rule instanceof Required) { |
|
| 25 | 1 | throw new UnexpectedRuleException(Required::class, $rule); |
|
| 26 | } |
||
| 27 | |||
| 28 | 19 | $result = new Result(); |
|
| 29 | |||
| 30 | 19 | if ($this->isEmpty(is_string($value) ? trim($value) : $value)) { |
|
| 31 | 5 | $result->addError($rule->message); |
|
| 32 | } |
||
| 33 | |||
| 34 | 19 | return $result; |
|
| 35 | } |
||
| 37 |