Utility   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A parseXml() 0 9 2
1
<?php
2
/**
3
 * Slince shipment tracker library
4
 * @author Tao <[email protected]>
5
 */
6
namespace Slince\ShipmentTracking;
7
8
use Slince\ShipmentTracking\Foundation\Exception\InvalidArgumentException;
9
10
final class Utility
11
{
12
    /**
13
     * Parse the xml to an array
14
     * @param string $xml
15
     * @throws
16
     * @return array
17
     */
18
    public static function parseXml($xml)
19
    {
20
        libxml_use_internal_errors(true);
21
        $data = simplexml_load_string($xml, null, LIBXML_NOERROR);
22
        if ($data === false) {
23
            throw new InvalidArgumentException(sprintf('Invalid xml response "%s"', $xml));
24
        }
25
        return json_decode(json_encode($data), true);
26
    }
27
}