| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | 39 | public function validate(mixed $value, object $rule, ValidationContext $context): Result |
|
| 22 | { |
||
| 23 | 39 | if (!$rule instanceof InRange) { |
|
| 24 | 1 | throw new UnexpectedRuleException(InRange::class, $rule); |
|
| 25 | } |
||
| 26 | |||
| 27 | 38 | $result = new Result(); |
|
| 28 | 38 | if ($rule->isNot() === ArrayHelper::isIn($value, $rule->getRange(), $rule->isStrict())) { |
|
| 29 | 22 | $result->addError( |
|
| 30 | 22 | $rule->getMessage(), |
|
| 31 | [ |
||
| 32 | 22 | 'attribute' => $context->getAttribute(), |
|
| 33 | 'value' => $value, |
||
| 34 | ], |
||
| 35 | ); |
||
| 36 | } |
||
| 37 | |||
| 38 | 38 | return $result; |
|
| 39 | } |
||
| 41 |