Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
20 | public function parse($file) |
||
21 | { |
||
22 | $config = json_decode(file_get_contents($file), true); |
||
23 | |||
24 | if (!is_array($config)) { |
||
25 | $error = json_last_error(); |
||
26 | |||
27 | if ($error === JSON_ERROR_NONE) { |
||
28 | $message = 'Invalid configuration format'; |
||
29 | } else { |
||
30 | $message = json_last_error_msg(); |
||
31 | } |
||
32 | |||
33 | throw new ParserException(sprintf('Couldn\'t parse config file %s: %s', $file, $message)); |
||
34 | } |
||
35 | |||
36 | return $config; |
||
37 | } |
||
38 | } |
||
39 |