Conditions | 4 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | 28 | public function validate(mixed $value, object $rule, ValidationContext $context): Result |
|
23 | { |
||
24 | 28 | if (!$rule instanceof Required) { |
|
25 | 1 | throw new UnexpectedRuleException(Required::class, $rule); |
|
26 | } |
||
27 | |||
28 | 27 | $result = new Result(); |
|
29 | |||
30 | 27 | if ($this->isEmpty(is_string($value) ? trim($value) : $value)) { |
|
31 | 13 | $result->addError( |
|
32 | 13 | message: $rule->getMessage(), |
|
33 | 13 | parameters: ['value' => $value] |
|
34 | ); |
||
35 | } |
||
36 | |||
37 | 27 | return $result; |
|
38 | } |
||
40 |