Conditions | 5 |
Paths | 5 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 5.5069 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
58 | 1 | public function asArray(iterable $rules): array |
|
59 | { |
||
60 | 1 | $rulesOfArray = []; |
|
61 | 1 | foreach ($rules as $attribute => $rulesSet) { |
|
62 | 1 | if (is_array($rulesSet)) { |
|
63 | 1 | $ruleSet = new RuleSet($rulesSet); |
|
64 | } |
||
65 | 1 | if (!$ruleSet instanceof RuleSet) { |
|
|
|||
66 | throw new InvalidArgumentException(sprintf( |
||
67 | 'Value should be an instance of %s or an array of rules, %s given.', |
||
68 | RuleSet::class, |
||
69 | is_object($ruleSet) ? get_class($ruleSet) : gettype($ruleSet) |
||
70 | )); |
||
71 | } |
||
72 | 1 | $rulesOfArray[$attribute] = $ruleSet->withFormatter($this->formatter)->asArray(); |
|
73 | } |
||
74 | 1 | return $rulesOfArray; |
|
75 | } |
||
84 |