Total Complexity | 9 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class CacheMap implements CacheMapInterface, Countable |
||
9 | { |
||
10 | private $cache = []; |
||
11 | |||
12 | 12 | public function get($key) |
|
13 | { |
||
14 | 12 | $key = $this->serializeKey($key); |
|
15 | |||
16 | 12 | return array_key_exists($key, $this->cache) |
|
17 | 3 | ? $this->cache[$key] |
|
18 | 12 | : false; |
|
19 | } |
||
20 | |||
21 | 12 | public function set($key, $value) |
|
22 | { |
||
23 | 12 | $this->cache[self::serializeKey($key)] = $value; |
|
24 | 12 | } |
|
25 | |||
26 | 1 | public function delete($key) |
|
27 | { |
||
28 | 1 | unset($this->cache[self::serializeKey($key)]); |
|
29 | 1 | } |
|
30 | |||
31 | 1 | public function clear() |
|
32 | { |
||
33 | 1 | $this->cache = []; |
|
34 | 1 | } |
|
35 | |||
36 | 1 | public function count() |
|
37 | { |
||
38 | 1 | return count($this->cache); |
|
39 | } |
||
40 | |||
41 | 12 | private static function serializeKey($key) |
|
49 | } |
||
50 | } |
||
51 |