| Conditions | 5 |
| Paths | 5 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 5.2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 51 | 1 | public function asArray(iterable $ruleSetMap): array |
|
| 52 | { |
||
| 53 | 1 | $arrayMap = []; |
|
| 54 | 1 | foreach ($ruleSetMap as $attribute => $ruleSet) { |
|
| 55 | 1 | if (is_array($ruleSet)) { |
|
| 56 | 1 | $ruleSet = new RuleSet($ruleSet); |
|
| 57 | } |
||
| 58 | |||
| 59 | 1 | if (!$ruleSet instanceof RuleSet) { |
|
| 60 | throw new InvalidArgumentException(sprintf( |
||
| 61 | 'Value should be an instance of %s or an array of rules, %s given.', |
||
| 62 | RuleSet::class, |
||
| 63 | is_object($ruleSet) ? get_class($ruleSet) : gettype($ruleSet) |
||
| 64 | )); |
||
| 65 | } |
||
| 66 | |||
| 67 | 1 | $arrayMap[$attribute] = $ruleSet->asArray(); |
|
| 68 | } |
||
| 69 | |||
| 70 | 1 | return $arrayMap; |
|
| 71 | } |
||
| 73 |