1: <?php
2:
3: namespace PHPixie\Config\Formats\Format;
4:
5: class JSON implements \PHPixie\Config\Formats\Format
6: {
7: public function read($file)
8: {
9: $data = json_decode(file_get_contents($file), true);
10:
11: if($data === null) {
12: throw new \PHPixie\Config\Exception("Invalid JSON in config file");
13: }
14:
15: return $data;
16: }
17:
18: public function write($file, $data)
19: {
20: file_put_contents($file, json_encode($data));
21: }
22: }
23: