Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
30 | 32 | public function validate(mixed $value, object $rule, ValidationContext $context): Result |
|
31 | { |
||
32 | 32 | if (!$rule instanceof InRange) { |
|
33 | 1 | throw new UnexpectedRuleException(InRange::class, $rule); |
|
34 | } |
||
35 | |||
36 | 31 | $result = new Result(); |
|
37 | 31 | if ($rule->isNot() === ArrayHelper::isIn($value, $rule->getRange(), $rule->isStrict())) { |
|
38 | 19 | $formattedMessage = $this->formatter->format( |
|
39 | 19 | $rule->getMessage(), |
|
40 | 19 | ['attribute' => $context->getAttribute(), 'value' => $value] |
|
41 | ); |
||
42 | 19 | $result->addError($formattedMessage); |
|
43 | } |
||
44 | |||
45 | 31 | return $result; |
|
46 | } |
||
48 |