| Conditions | 3 |
| Paths | 3 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 6 | public function parse($config, $filename = null) |
|
| 26 | { |
||
| 27 | 6 | $data = json_decode($config, true); |
|
| 28 | |||
| 29 | 6 | if (json_last_error() !== JSON_ERROR_NONE) { |
|
| 30 | 3 | $error_message = 'Syntax error'; |
|
| 31 | 3 | if (function_exists('json_last_error_msg')) { |
|
| 32 | 3 | $error_message = json_last_error_msg(); |
|
| 33 | 1 | } |
|
| 34 | |||
| 35 | $error = [ |
||
| 36 | 3 | 'message' => $error_message, |
|
| 37 | 3 | 'type' => json_last_error(), |
|
| 38 | 3 | 'file' => $filename, |
|
| 39 | 1 | ]; |
|
| 40 | 3 | throw new ParseException($error); |
|
| 41 | } |
||
| 42 | |||
| 43 | 3 | return $data; |
|
| 44 | } |
||
| 45 | |||
| 54 |