| @@ 57-73 (lines=17) @@ | ||
| 54 | * @param string $file |
|
| 55 | * @return array $config |
|
| 56 | */ |
|
| 57 | public static function getConfigFile($file): array |
|
| 58 | { |
|
| 59 | $file = addslashes($file); |
|
| 60 | if (is_file($file)) { |
|
| 61 | $data = str_replace("\\", "\\\\", file_get_contents($file)); |
|
| 62 | $json = json_decode($data, true); |
|
| 63 | ||
| 64 | if (empty($json)) { |
|
| 65 | throw new \Exception("Config file has a json parse error, $file"); |
|
| 66 | } |
|
| 67 | ||
| 68 | } else { |
|
| 69 | throw new \Exception("Config file not found, $file"); |
|
| 70 | } |
|
| 71 | ||
| 72 | return $json; |
|
| 73 | } |
|
| 74 | } |
|
| @@ 58-74 (lines=17) @@ | ||
| 55 | * @param string $file |
|
| 56 | * @return array $config |
|
| 57 | */ |
|
| 58 | public static function getConfigFile($filename) |
|
| 59 | { |
|
| 60 | $filename = addslashes($filename); |
|
| 61 | if (is_file($filename)) { |
|
| 62 | $data = str_replace("\\", "\\\\", file_get_contents($filename)); |
|
| 63 | $json = json_decode($data, true); |
|
| 64 | ||
| 65 | if (empty($json)) { |
|
| 66 | throw new \Exception("Config file has a json parse error, $filename"); |
|
| 67 | } |
|
| 68 | ||
| 69 | } else { |
|
| 70 | throw new \Exception("Config file not found, $filename"); |
|
| 71 | } |
|
| 72 | ||
| 73 | return $json; |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * Get configuration |
|