| Total Complexity | 10 |
| Total Lines | 77 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class RuntimeCache implements CacheInterface |
||
| 8 | { |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @var array |
||
| 12 | */ |
||
| 13 | protected $cache = []; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @inheritdoc |
||
| 17 | */ |
||
| 18 | public function get($key, $default = null) |
||
| 19 | { |
||
| 20 | return $this->cache[$key] ?? $default; |
||
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @inheritdoc |
||
| 25 | */ |
||
| 26 | public function has($key): bool |
||
| 27 | { |
||
| 28 | return isset($this->cache[$key]); |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @inheritdoc |
||
| 33 | */ |
||
| 34 | public function delete($key): bool |
||
| 35 | { |
||
| 36 | unset($this->cache[$key]); |
||
| 37 | return true; |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @inheritdoc |
||
| 42 | */ |
||
| 43 | public function set($key, $value, $ttl = null): bool |
||
| 44 | { |
||
| 45 | $this->cache[$key] = $value; |
||
| 46 | return true; |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @inheritdoc |
||
| 51 | */ |
||
| 52 | public function clear() |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @inheritdoc |
||
| 59 | */ |
||
| 60 | public function getMultiple($keys, $default = null) |
||
| 61 | { |
||
| 62 | return array_filter($this->cache, function ($key) use ($keys) { |
||
| 63 | return \in_array($key, $keys, true); |
||
| 64 | }, ARRAY_FILTER_USE_KEY); |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @inheritdoc |
||
| 69 | */ |
||
| 70 | public function setMultiple($values, $ttl = null) |
||
| 71 | { |
||
| 72 | foreach ($values as $key => $value) { |
||
| 73 | $this->set($key, $value); |
||
| 74 | } |
||
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @inheritdoc |
||
| 79 | */ |
||
| 80 | public function deleteMultiple($keys) |
||
| 84 | } |
||
| 85 | } |
||
| 86 | } |
||
| 87 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: