Total Complexity | 5 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | class RuntimeCache implements CacheInterface |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * @var array |
||
10 | */ |
||
11 | private $_cache = []; |
||
12 | |||
13 | /** |
||
14 | * @inheritdoc |
||
15 | */ |
||
16 | public function getItem(string $key) |
||
17 | { |
||
18 | return $this->_cache[$key] ?? null; |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * @inheritdoc |
||
23 | */ |
||
24 | public function hasItem(string $key): bool |
||
25 | { |
||
26 | return isset($this->_cache[$key]); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param string $key |
||
31 | * @return bool |
||
32 | */ |
||
33 | public function deleteItem(string $key): bool |
||
34 | { |
||
35 | unset($this->_cache[$key]); |
||
36 | return true; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @param string $key |
||
41 | * @param mixed $value |
||
42 | * @return bool |
||
43 | */ |
||
44 | public function setItem(string $key, $value): bool |
||
45 | { |
||
46 | $this->_cache[$key] = $value; |
||
47 | return true; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @return bool |
||
52 | */ |
||
53 | public function commit(): bool |
||
56 | } |
||
57 | } |
||
58 |