Conditions | 7 |
Paths | 6 |
Total Lines | 17 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 7.1782 |
Changes | 0 |
1 | <?php |
||
41 | 148 | public static function getArrayForItems($items) |
|
42 | { |
||
43 | 148 | if ($items instanceof Collection) { |
|
44 | 8 | return $items->toArray(); |
|
45 | 146 | } elseif (is_array($items)) { |
|
46 | 144 | return $items; |
|
47 | 5 | } elseif ($items instanceof Traversable) { |
|
48 | 1 | return iterator_to_array($items); |
|
49 | 4 | } elseif (is_string($items)) { |
|
50 | 4 | $json = json_decode($items, true); |
|
51 | 4 | if (is_array($json) && json_last_error() == JSON_ERROR_NONE) { |
|
52 | 4 | return $json; |
|
53 | } |
||
54 | } |
||
55 | |||
56 | return (array)$items; |
||
57 | } |
||
58 | } |
||
59 |