1 | <?php |
||
8 | class ArrayCache implements CacheInterface |
||
9 | { |
||
10 | |||
11 | private $defaultTtl; |
||
12 | private $storage = []; |
||
13 | private $expiries = []; |
||
14 | |||
15 | /** |
||
16 | * ArrayCache constructor. |
||
17 | * @param int|null $defaultTtl |
||
18 | */ |
||
19 | public function __construct(int $defaultTtl = null) |
||
23 | |||
24 | /** |
||
25 | * @inheritDoc |
||
26 | */ |
||
27 | public function get($key, $default = null) |
||
37 | |||
38 | /** |
||
39 | * @inheritDoc |
||
40 | */ |
||
41 | public function set($key, $value, $ttl = null) |
||
46 | |||
47 | /** |
||
48 | * @inheritDoc |
||
49 | */ |
||
50 | public function delete($key) |
||
54 | |||
55 | /** |
||
56 | * @inheritDoc |
||
57 | */ |
||
58 | public function clear() |
||
63 | |||
64 | /** |
||
65 | * @inheritDoc |
||
66 | */ |
||
67 | public function getMultiple($keys, $default = null) |
||
73 | |||
74 | /** |
||
75 | * @inheritDoc |
||
76 | */ |
||
77 | public function setMultiple($values, $ttl = null) |
||
83 | |||
84 | /** |
||
85 | * @inheritDoc |
||
86 | */ |
||
87 | public function deleteMultiple($keys) |
||
93 | |||
94 | /** |
||
95 | * @inheritDoc |
||
96 | */ |
||
97 | public function has($key) |
||
101 | |||
102 | /** |
||
103 | * @param $values |
||
104 | * @return bool |
||
105 | */ |
||
106 | private function isIterable($values): bool |
||
110 | |||
111 | /** |
||
112 | * @param int|null $ttl |
||
113 | * @return int|null |
||
114 | */ |
||
115 | private function computeExpiryTime(int $ttl = null): ?int |
||
123 | |||
124 | /** |
||
125 | * @param $key |
||
126 | * @return bool |
||
127 | */ |
||
128 | private function isExpired($key): bool |
||
135 | } |
||
136 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.