| Conditions | 3 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | public static function readJsonFile($file) |
||
| 36 | { |
||
| 37 | if (!is_file($file)) { |
||
| 38 | throw new InvalidArgumentException(sprintf("File [%s] does not exists", $file)); |
||
| 39 | } |
||
| 40 | $rawContent = @file_get_contents($file); |
||
| 41 | $data = json_decode($rawContent, true); |
||
| 42 | if (json_last_error()) { |
||
| 43 | throw new InvalidArgumentException(sprintf("File [%s] must contain valid json, error: %s", $file, json_last_error_msg())); |
||
| 44 | } |
||
| 45 | return $data; |
||
| 46 | } |
||
| 47 | } |
||
| 48 |