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