| Conditions | 7 |
| Paths | 5 |
| Total Lines | 31 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 17 |
| CRAP Score | 7 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | 43 | private function validateLimits( |
|
| 13 | mixed $value, |
||
| 14 | object $rule, |
||
| 15 | ValidationContext $context, |
||
| 16 | int $number, |
||
| 17 | Result $result |
||
| 18 | ): void { |
||
| 19 | 43 | if ($rule->getExactly() !== null && $number !== $rule->getExactly()) { |
|
| 20 | 3 | $formattedMessage = $this->formatter->format( |
|
| 21 | 3 | $rule->getNotExactlyMessage(), |
|
| 22 | 3 | ['exactly' => $rule->getExactly(), 'attribute' => $context->getAttribute(), 'value' => $value] |
|
| 23 | ); |
||
| 24 | 3 | $result->addError($formattedMessage); |
|
| 25 | |||
| 26 | 3 | return; |
|
| 27 | } |
||
| 28 | |||
| 29 | 40 | if ($rule->getMin() !== null && $number < $rule->getMin()) { |
|
| 30 | 13 | $formattedMessage = $this->formatter->format( |
|
| 31 | 13 | $rule->getLessThanMinMessage(), |
|
| 32 | 13 | ['min' => $rule->getMin(), 'attribute' => $context->getAttribute(), 'value' => $value] |
|
| 33 | ); |
||
| 34 | 13 | $result->addError($formattedMessage); |
|
| 35 | } |
||
| 36 | |||
| 37 | 40 | if ($rule->getMax() !== null && $number > $rule->getMax()) { |
|
| 38 | 4 | $formattedMessage = $this->formatter->format( |
|
| 39 | 4 | $rule->getGreaterThanMaxMessage(), |
|
| 40 | 4 | ['max' => $rule->getMax(), 'attribute' => $context->getAttribute(), 'value' => $value] |
|
| 41 | ); |
||
| 42 | 4 | $result->addError($formattedMessage); |
|
| 43 | } |
||
| 46 |