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