| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 6 | public function validate(mixed $value, object $rule, ?ValidationContext $context = null): Result |
|
| 26 | { |
||
| 27 | 6 | if (!$rule instanceof GroupRule) { |
|
| 28 | 1 | throw new UnexpectedRuleException(GroupRule::class, $rule); |
|
| 29 | } |
||
| 30 | |||
| 31 | 5 | $result = new Result(); |
|
| 32 | 5 | if (!$context?->getValidator()->validate($value, $rule->getRuleSet())->isValid()) { |
|
| 33 | 4 | $formattedMessage = $this->formatter->format( |
|
| 34 | 4 | $rule->getMessage(), |
|
| 35 | 4 | ['attribute' => $context?->getAttribute(), 'value' => $value] |
|
| 36 | ); |
||
| 37 | 4 | $result->addError($formattedMessage); |
|
| 38 | } |
||
| 39 | |||
| 40 | 5 | return $result; |
|
| 41 | } |
||
| 43 |