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