| Conditions | 2 |
| Paths | 2 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 6 | public function parse($config, $filename = null) |
|
| 26 | { |
||
| 27 | 6 | libxml_use_internal_errors(true); |
|
| 28 | |||
| 29 | 6 | $data = simplexml_load_string($config, null, LIBXML_NOERROR); |
|
| 30 | |||
| 31 | 6 | if ($data === false) { |
|
| 32 | 3 | $errors = libxml_get_errors(); |
|
| 33 | 3 | $latestError = array_pop($errors); |
|
| 34 | $error = [ |
||
| 35 | 3 | 'message' => $latestError->message, |
|
| 36 | 3 | 'type' => $latestError->level, |
|
| 37 | 3 | 'code' => $latestError->code, |
|
| 38 | 3 | 'file' => $filename, |
|
| 39 | 3 | 'line' => $latestError->line, |
|
| 40 | 1 | ]; |
|
| 41 | 3 | throw new ParseException($error); |
|
| 42 | } |
||
| 43 | |||
| 44 | 3 | $data = json_decode(json_encode($data), true); |
|
| 45 | |||
| 46 | 3 | return $data; |
|
| 47 | } |
||
| 48 | |||
| 57 |