| Total Complexity | 7 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | class Cache |
||
| 6 | { |
||
| 7 | private $checkIdentifier; |
||
| 8 | |||
| 9 | private $cacheDir = '/tmp/cache/'; |
||
| 10 | |||
| 11 | public function __construct($checkIdentifier) |
||
| 12 | { |
||
| 13 | if (!file_exists($this->cacheDir)) { |
||
| 14 | mkdir($this->cacheDir, 0777, true); |
||
| 15 | } |
||
| 16 | $this->checkIdentifier = $checkIdentifier; |
||
| 17 | } |
||
| 18 | |||
| 19 | public function set($key, $value) |
||
| 20 | { |
||
| 21 | file_put_contents($this->getFilename($key), $value); |
||
| 22 | } |
||
| 23 | |||
| 24 | public function get($key) |
||
| 25 | { |
||
| 26 | $file = $this->getFilename($key); |
||
| 27 | |||
| 28 | if (file_exists($file)) { |
||
| 29 | return file_get_contents($file); |
||
| 30 | } else { |
||
| 31 | return null; |
||
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | private function getGlobalKey($key) |
||
| 38 | } |
||
| 39 | |||
| 40 | private function getFilename($key) |
||
| 44 | } |
||
| 45 | } |
||
| 46 |