Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 3.0026 |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
25 | 6 | public function parse($path) |
|
26 | { |
||
27 | 6 | $data = simplexml_load_file($path, 'SimpleXMLElement', LIBXML_NOWARNING | LIBXML_NOERROR); |
|
28 | |||
29 | 6 | if ($data === false) { |
|
30 | 3 | $lastError = libxml_get_last_error(); |
|
31 | 3 | if ($lastError !== false) { |
|
32 | 3 | throw new ParseException([ |
|
33 | 3 | 'message' => $lastError->message, |
|
34 | 3 | 'type' => $lastError->level, |
|
35 | 3 | 'code' => $lastError->code, |
|
36 | 3 | 'file' => $lastError->file, |
|
37 | 3 | 'line' => $lastError->line, |
|
38 | 2 | ]); |
|
39 | } |
||
40 | } |
||
41 | |||
42 | 3 | $data = json_decode(json_encode($data), true); |
|
43 | |||
44 | 3 | return $data; |
|
45 | } |
||
46 | |||
57 |