| Conditions | 5 |
| Paths | 5 |
| Total Lines | 17 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 5.9256 |
| 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 | $rulesSet = new Rules($rulesSet); |
|
| 64 | } |
||
| 65 | 1 | if (!$rulesSet instanceof Rules) { |
|
| 66 | throw new InvalidArgumentException(sprintf( |
||
| 67 | 'Value should be an instance of %s or an array of rules, %s given.', |
||
| 68 | Rules::class, |
||
| 69 | is_object($rulesSet) ? get_class($rulesSet) : gettype($rulesSet) |
||
| 70 | )); |
||
| 71 | } |
||
| 72 | 1 | $rulesOfArray[$attribute] = $rulesSet->withFormatter($this->formatter)->asArray(); |
|
| 73 | } |
||
| 74 | 1 | return $rulesOfArray; |
|
| 75 | } |
||
| 84 |