Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | public function validate($value, object $rule, ValidationContext $context): Result |
||
22 | { |
||
23 | if (!$rule instanceof StringValue) { |
||
24 | throw new UnexpectedRuleException(StringValue::class, $rule); |
||
25 | } |
||
26 | |||
27 | if (!is_string($value)) { |
||
28 | return (new Result())->addError($rule->getMessage(), [ |
||
29 | 'attribute' => $context->getTranslatedAttribute(), |
||
30 | 'type' => get_debug_type($value), |
||
31 | ]); |
||
32 | } |
||
33 | |||
34 | return new Result(); |
||
35 | } |
||
37 |