| Conditions | 5 |
| Paths | 5 |
| Total Lines | 19 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 4 |
| CRAP Score | 5.9256 |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 55 | 1 | private function fetchOptions(iterable $rules): array |
|
| 56 | { |
||
| 57 | $result = []; |
||
| 58 | 1 | foreach ($rules as $attribute => $rule) { |
|
| 59 | if (is_array($rule)) { |
||
| 60 | $result[$attribute] = $this->fetchOptions($rule); |
||
| 61 | } elseif ($rule instanceof ParametrizedRuleInterface) { |
||
| 62 | $result[$attribute] = array_merge([$rule->getName()], $rule->getOptions()); |
||
| 63 | } elseif ($rule instanceof RuleInterface) { |
||
| 64 | $result[$attribute] = [$rule->getName()]; |
||
| 65 | } else { |
||
| 66 | 1 | throw new InvalidArgumentException(sprintf( |
|
| 67 | 'Rules should be a rule or an array of rules that implements %s.', |
||
| 68 | RuleInterface::class, |
||
| 69 | 1 | )); |
|
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | return $result; |
||
| 74 | } |
||
| 76 |