@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param \chillerlan\SimpleCache\Drivers\CacheDriverInterface $cacheDriver |
38 | 38 | * @param \Psr\Log\LoggerInterface $logger |
39 | 39 | */ |
40 | - public function __construct(CacheDriverInterface $cacheDriver, LoggerInterface $logger = null){ |
|
40 | + public function __construct(CacheDriverInterface $cacheDriver, LoggerInterface $logger = null) { |
|
41 | 41 | $this->cacheDriver = $cacheDriver; |
42 | 42 | $this->setLogger($logger ?? new NullLogger); |
43 | 43 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | /** @inheritdoc */ |
58 | - public function get($key, $default = null){ |
|
58 | + public function get($key, $default = null) { |
|
59 | 59 | $this->checkKey($key); |
60 | 60 | |
61 | 61 | return $this->cacheDriver->get($key, $default); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public function setMultiple($values, $ttl = null):bool{ |
93 | 93 | $values = $this->getData($values); |
94 | 94 | |
95 | - foreach($values as $key => $value){ |
|
95 | + foreach ($values as $key => $value) { |
|
96 | 96 | $this->checkKey($key); |
97 | 97 | } |
98 | 98 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | protected function checkKey($key):void{ |
124 | 124 | |
125 | - if(!is_string($key) || empty($key)){ |
|
125 | + if (!is_string($key) || empty($key)) { |
|
126 | 126 | $msg = 'invalid cache key: "'.$key.'"'; |
127 | 127 | $this->logger->error($msg); |
128 | 128 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | protected function checkKeyArray(array $keys):void{ |
140 | 140 | |
141 | - foreach($keys as $key){ |
|
141 | + foreach ($keys as $key) { |
|
142 | 142 | $this->checkKey($key); |
143 | 143 | } |
144 | 144 | |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | */ |
153 | 153 | protected function getData($data):array{ |
154 | 154 | |
155 | - if($data instanceof Traversable){ |
|
155 | + if ($data instanceof Traversable) { |
|
156 | 156 | return iterator_to_array($data); // @codeCoverageIgnore |
157 | 157 | } |
158 | - else if(is_array($data)){ |
|
158 | + else if (is_array($data)) { |
|
159 | 159 | return $data; |
160 | 160 | } |
161 | 161 | |
@@ -171,12 +171,12 @@ discard block |
||
171 | 171 | * @return int|null |
172 | 172 | * @throws \chillerlan\SimpleCache\InvalidArgumentException |
173 | 173 | */ |
174 | - protected function getTTL($ttl):?int{ |
|
174 | + protected function getTTL($ttl): ?int{ |
|
175 | 175 | |
176 | - if($ttl instanceof DateInterval){ |
|
176 | + if ($ttl instanceof DateInterval) { |
|
177 | 177 | return (new DateTime('now'))->add($ttl)->getTimeStamp() - time(); |
178 | 178 | } |
179 | - else if(is_int($ttl) || $ttl === null){ |
|
179 | + else if (is_int($ttl) || $ttl === null) { |
|
180 | 180 | return $ttl; |
181 | 181 | } |
182 | 182 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @throws \chillerlan\SimpleCache\CacheException |
193 | 193 | */ |
194 | - protected function throwException(string $message){ |
|
194 | + protected function throwException(string $message) { |
|
195 | 195 | $this->logger->error($message); |
196 | 196 | |
197 | 197 | throw new InvalidArgumentException($message); |
@@ -154,8 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | if($data instanceof Traversable){ |
156 | 156 | return iterator_to_array($data); // @codeCoverageIgnore |
157 | - } |
|
158 | - else if(is_array($data)){ |
|
157 | + } else if(is_array($data)){ |
|
159 | 158 | return $data; |
160 | 159 | } |
161 | 160 | |
@@ -175,8 +174,7 @@ discard block |
||
175 | 174 | |
176 | 175 | if($ttl instanceof DateInterval){ |
177 | 176 | return (new DateTime('now'))->add($ttl)->getTimeStamp() - time(); |
178 | - } |
|
179 | - else if(is_int($ttl) || $ttl === null){ |
|
177 | + } else if(is_int($ttl) || $ttl === null){ |
|
180 | 178 | return $ttl; |
181 | 179 | } |
182 | 180 |
@@ -12,4 +12,4 @@ |
||
12 | 12 | |
13 | 13 | namespace chillerlan\SimpleCache; |
14 | 14 | |
15 | -class InvalidArgumentException extends CacheException implements \Psr\SimpleCache\InvalidArgumentException{} |
|
15 | +class InvalidArgumentException extends CacheException implements \Psr\SimpleCache\InvalidArgumentException {} |
@@ -18,6 +18,6 @@ |
||
18 | 18 | * @property string $filestorage |
19 | 19 | * @property string $cachekey |
20 | 20 | */ |
21 | -class CacheOptions extends ImmutableSettingsAbstract{ |
|
21 | +class CacheOptions extends ImmutableSettingsAbstract { |
|
22 | 22 | use CacheOptionsTrait; |
23 | 23 | } |