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