| 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 | 0 |
| 1 | <?php |
||
| 47 | 1 | public function asArray(iterable $rules): array |
|
| 48 | { |
||
| 49 | 1 | $rulesOfArray = []; |
|
| 50 | 1 | foreach ($rules as $attribute => $rulesSet) { |
|
| 51 | 1 | if (is_array($rulesSet)) { |
|
| 52 | 1 | $rulesSet = new Rules($rulesSet); |
|
| 53 | } |
||
| 54 | 1 | if (!$rulesSet instanceof Rules) { |
|
| 55 | throw new \InvalidArgumentException(sprintf( |
||
| 56 | 'Value should be instance of %s or an array of rules, %s given.', |
||
| 57 | Rules::class, |
||
| 58 | is_object($rulesSet) ? get_class($rulesSet) : gettype($rulesSet) |
||
| 59 | )); |
||
| 60 | } |
||
| 61 | 1 | $rulesOfArray[$attribute] = $rulesSet->withFormatter($this->formatter)->asArray(); |
|
| 62 | } |
||
| 63 | 1 | return $rulesOfArray; |
|
| 64 | } |
||
| 73 |