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