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