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