Conditions | 4 |
Paths | 4 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4.0218 |
Changes | 0 |
1 | <?php |
||
18 | 13 | public static function parse(string $xml) |
|
19 | { |
||
20 | 13 | if (!$obj = simplexml_load_string($xml)) { |
|
21 | return []; |
||
22 | } |
||
23 | 13 | if ($obj->attributes()) { |
|
24 | 6 | $items = []; |
|
25 | 6 | foreach ($obj->children() as $child) { |
|
26 | 6 | $items[] = static::flatten($child); |
|
27 | } |
||
28 | 6 | return Collection::make($items); |
|
29 | } |
||
30 | 7 | return (array) static::flatten($obj); |
|
31 | } |
||
48 |