| Conditions | 5 |
| Paths | 7 |
| Total Lines | 21 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | 6 | public function validate(mixed $value, object $rule, ValidatorInterface $validator, ?ValidationContext $context = null): Result |
|
| 22 | { |
||
| 23 | 6 | if (!$rule instanceof AtLeast) { |
|
| 24 | 1 | throw new UnexpectedRuleException(AtLeast::class, $rule); |
|
| 25 | } |
||
| 26 | |||
| 27 | 5 | $filledCount = 0; |
|
| 28 | |||
| 29 | 5 | foreach ($rule->attributes as $attribute) { |
|
| 30 | 5 | if (!$this->isEmpty($value->{$attribute})) { |
|
| 31 | 4 | $filledCount++; |
|
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | 5 | $result = new Result(); |
|
| 36 | |||
| 37 | 5 | if ($filledCount < $rule->min) { |
|
| 38 | 3 | $result->addError($rule->message, ['min' => $rule->min]); |
|
| 39 | } |
||
| 40 | |||
| 41 | 5 | return $result; |
|
| 42 | } |
||
| 44 |