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