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 |
||
55 | 6 | private function fetchOptions(iterable $rules): array |
|
56 | { |
||
57 | 6 | $result = []; |
|
58 | 6 | foreach ($rules as $attribute => $rule) { |
|
59 | 6 | if (is_array($rule)) { |
|
60 | 2 | $result[$attribute] = $this->fetchOptions($rule); |
|
61 | 6 | } elseif ($rule instanceof ParametrizedRuleInterface) { |
|
62 | 6 | $result[$attribute] = array_merge([$rule->getName()], $rule->getOptions()); |
|
63 | } elseif ($rule instanceof RuleInterface) { |
||
64 | $result[$attribute] = [$rule->getName()]; |
||
65 | } else { |
||
66 | throw new InvalidArgumentException(sprintf( |
||
67 | 'Rules should be a rule or an array of rules that implements %s.', |
||
68 | RuleInterface::class, |
||
69 | )); |
||
70 | } |
||
71 | } |
||
72 | |||
73 | 6 | return $result; |
|
74 | } |
||
76 |