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