| Conditions | 3 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 39 | public function validate(mixed $value, object $rule, ValidationContext $context): Result |
|
| 19 | { |
||
| 20 | 39 | if (!$rule instanceof In) { |
|
| 21 | 1 | throw new UnexpectedRuleException(In::class, $rule); |
|
| 22 | } |
||
| 23 | |||
| 24 | 38 | $result = new Result(); |
|
| 25 | 38 | if ($rule->isNot() === ArrayHelper::isIn($value, $rule->getValues(), $rule->isStrict())) { |
|
| 26 | 22 | $result->addError($rule->getMessage(), ['attribute' => $context->getAttribute()]); |
|
| 27 | } |
||
| 28 | |||
| 29 | 38 | return $result; |
|
| 30 | } |
||
| 32 |