6 * File data storage functionality.
15 * @param string $key Storage key
16 * @param unknown $data Data to store
19 static public function existsJson($key)
21 return file_exists(getcwd() . '/data/file/' . $key . '.json');
26 * @param string $key Storage key
27 * @param array $data Data to store
30 static public function storeJson($key, $data)
32 file_put_contents(getcwd() . '/data/file/' . $key . '.json', json_encode($data));
36 * Retrieve data from file.
37 * @param string $key Storage key
38 * @return unknown Stored data or null
40 static public function fetchJson($key)
42 if (!file_exists(getcwd() . '/data/file/' . $key . '.json'))
46 $result = file_get_contents(getcwd() . '/data/file/' . $key . '.json');
47 return json_decode($result, true);
52 * @param string $key Storage key
55 static public function deleteJson($key)
57 if (file_exists(getcwd() . '/data/file/' . $key . '.json'))
59 unlink(getcwd() . '/data/file/' . $key . '.json');
65 * @param string $key Storage key
66 * @param unknown $data Data to store
69 static public function storeText($key, $data)
71 file_put_contents(getcwd() . '/data/file/' . $key . '.txt', $data);
75 * Retrieve data from file.
76 * @param string $key Storage key
77 * @return unknown Stored data or null
79 static public function fetchText($key)
81 if (!file_exists(getcwd() . '/data/file/' . $key . '.txt'))
85 return file_get_contents(getcwd() . '/data/file/' . $key . '.txt');
90 * @param string $key Storage key
93 static public function deleteText($key)
95 if (file_exists(getcwd() . '/data/file/' . $key . '.txt'))
97 unlink(getcwd() . '/data/file/' . $key . '.txt');