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