Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 3.1172 |
Changes | 0 |
1 | <?php |
||
24 | 4 | public function parse($path) |
|
25 | { |
||
26 | 4 | $data = json_decode(file_get_contents($path), true); |
|
27 | |||
28 | 4 | if (json_last_error() !== JSON_ERROR_NONE) { |
|
29 | 2 | $error_message = 'Syntax error'; |
|
30 | 2 | if (function_exists('json_last_error_msg')) { |
|
31 | 1 | $error_message = json_last_error_msg(); |
|
32 | 1 | } |
|
33 | |||
34 | $error = array( |
||
35 | 2 | 'message' => $error_message, |
|
36 | 2 | 'type' => json_last_error(), |
|
37 | 2 | 'file' => $path, |
|
38 | 2 | ); |
|
39 | 2 | throw new ParseException($error); |
|
40 | } |
||
41 | |||
42 | 2 | return $data; |
|
43 | } |
||
44 | |||
53 |