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