@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | { |
40 | 40 | $key = 21021000; |
41 | 41 | $this->expectException(InvalidArgumentException::class); |
42 | - $this->cache->set($key,'value'); |
|
42 | + $this->cache->set($key, 'value'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | /** |
206 | 206 | * |
207 | 207 | */ |
208 | - public function testGetMultiple(){ |
|
208 | + public function testGetMultiple() { |
|
209 | 209 | |
210 | 210 | $expected = [ |
211 | 211 | 'foo' => 'fooValue', |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | $i = 0; |
217 | 217 | |
218 | - foreach ($expected as $key => $value){ |
|
218 | + foreach ($expected as $key => $value) { |
|
219 | 219 | |
220 | 220 | $this->storageMock->expects($this->at($i)) |
221 | 221 | ->method('get') |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | /** |
236 | 236 | * |
237 | 237 | */ |
238 | - public function testSetMultiple(){ |
|
238 | + public function testSetMultiple() { |
|
239 | 239 | |
240 | 240 | $keys = [ |
241 | 241 | 'foo' => 'fooValue', |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $i = 0; |
250 | 250 | $expires = 60 * 60; |
251 | 251 | |
252 | - foreach ($keys as $key => $value){ |
|
252 | + foreach ($keys as $key => $value) { |
|
253 | 253 | $this->storageMock->expects($this->at($i)) |
254 | 254 | ->method('set') |
255 | 255 | ->with( |
@@ -261,20 +261,20 @@ discard block |
||
261 | 261 | $i++; |
262 | 262 | } |
263 | 263 | |
264 | - $actual = $this->cache->setMultiple($keys,$expires); |
|
264 | + $actual = $this->cache->setMultiple($keys, $expires); |
|
265 | 265 | $this->assertEquals($expected, $actual); |
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
269 | 269 | * |
270 | 270 | */ |
271 | - public function testDeleteMultiple(){ |
|
271 | + public function testDeleteMultiple() { |
|
272 | 272 | |
273 | - $keys = ['foo','bar','baz']; |
|
273 | + $keys = ['foo', 'bar', 'baz']; |
|
274 | 274 | $deleteStatus = true; |
275 | 275 | $expected = true; |
276 | 276 | |
277 | - foreach ($keys as $i => $key){ |
|
277 | + foreach ($keys as $i => $key) { |
|
278 | 278 | $this->storageMock->expects($this->at($i)) |
279 | 279 | ->method('delete') |
280 | 280 | ->with( |
@@ -290,15 +290,15 @@ discard block |
||
290 | 290 | /** |
291 | 291 | * |
292 | 292 | */ |
293 | - public function testDeleteMultipleFailure(){ |
|
293 | + public function testDeleteMultipleFailure() { |
|
294 | 294 | |
295 | - $keys = ['foo','bar','baz']; |
|
295 | + $keys = ['foo', 'bar', 'baz']; |
|
296 | 296 | $expected = false; |
297 | 297 | $deleteStatus = true; |
298 | 298 | |
299 | - foreach ($keys as $i => $key){ |
|
299 | + foreach ($keys as $i => $key) { |
|
300 | 300 | |
301 | - if ($i === 1){ |
|
301 | + if ($i === 1) { |
|
302 | 302 | $deleteStatus = false; |
303 | 303 | } |
304 | 304 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | /** |
318 | 318 | * Test that storage clear is called. |
319 | 319 | */ |
320 | - public function testclear(){ |
|
320 | + public function testclear() { |
|
321 | 321 | $this->storageMock->expects($this->once()) |
322 | 322 | ->method('clear'); |
323 | 323 | $this->cache->clear(); |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | /** |
327 | 327 | * Test that array has keys. |
328 | 328 | */ |
329 | - public function testArrayHasKeys(){ |
|
329 | + public function testArrayHasKeys() { |
|
330 | 330 | $data = ['a' => 'foo', 'b' => 'bar']; |
331 | 331 | |
332 | 332 | $reflector = new \ReflectionClass(Cache::class); |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | /** |
341 | 341 | * Test exception thrown when array is missing keys. |
342 | 342 | */ |
343 | - public function testArrayHasNoKeys(){ |
|
343 | + public function testArrayHasNoKeys() { |
|
344 | 344 | $this->expectException(InvalidArgumentException::class); |
345 | - $data = ['foo','bar']; |
|
345 | + $data = ['foo', 'bar']; |
|
346 | 346 | $reflector = new \ReflectionClass(Cache::class); |
347 | 347 | $method = $reflector->getMethod('_hasKeys'); |
348 | 348 | $method->setAccessible(true); |
@@ -352,8 +352,8 @@ discard block |
||
352 | 352 | /** |
353 | 353 | * Test array contains a failure. |
354 | 354 | */ |
355 | - public function testHasFailure(){ |
|
356 | - $results = [true,true,true,false,true]; |
|
355 | + public function testHasFailure() { |
|
356 | + $results = [true, true, true, false, true]; |
|
357 | 357 | $reflector = new \ReflectionClass(Cache::class); |
358 | 358 | $method = $reflector->getMethod('_hasFailure'); |
359 | 359 | $method->setAccessible(true); |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | /** |
366 | 366 | * Test array doesn't contain a failure. |
367 | 367 | */ |
368 | - public function testHasNoFailure(){ |
|
369 | - $results = [true,true,true,true,true]; |
|
368 | + public function testHasNoFailure() { |
|
369 | + $results = [true, true, true, true, true]; |
|
370 | 370 | $reflector = new \ReflectionClass(Cache::class); |
371 | 371 | $method = $reflector->getMethod('_hasFailure'); |
372 | 372 | $method->setAccessible(true); |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | /** |
379 | 379 | * Test that array is Traversable |
380 | 380 | */ |
381 | - public function testIsTraversable(){ |
|
382 | - $data = ['a','b','c','d']; |
|
381 | + public function testIsTraversable() { |
|
382 | + $data = ['a', 'b', 'c', 'd']; |
|
383 | 383 | $reflector = new \ReflectionClass(Cache::class); |
384 | 384 | $method = $reflector->getMethod('_isTraversable'); |
385 | 385 | $method->setAccessible(true); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | /** |
392 | 392 | * Test that string is not Traversable |
393 | 393 | */ |
394 | - public function testIsNotTraversable(){ |
|
394 | + public function testIsNotTraversable() { |
|
395 | 395 | $this->expectException(InvalidArgumentException::class); |
396 | 396 | $data = 'some-random-string'; |
397 | 397 | $reflector = new \ReflectionClass(Cache::class); |
@@ -403,13 +403,13 @@ discard block |
||
403 | 403 | /** |
404 | 404 | * Test that instance of Iterator is traversable |
405 | 405 | */ |
406 | - public function testIsTraversableIterator(){ |
|
406 | + public function testIsTraversableIterator() { |
|
407 | 407 | $iterator = new class implements \Iterator { |
408 | - public function current(){} |
|
409 | - public function next(){} |
|
410 | - public function key(){} |
|
411 | - public function valid(){} |
|
412 | - public function rewind(){} |
|
408 | + public function current() {} |
|
409 | + public function next() {} |
|
410 | + public function key() {} |
|
411 | + public function valid() {} |
|
412 | + public function rewind() {} |
|
413 | 413 | }; |
414 | 414 | $reflector = new \ReflectionClass(Cache::class); |
415 | 415 | $method = $reflector->getMethod('_isTraversable'); |
@@ -423,11 +423,11 @@ discard block |
||
423 | 423 | /** |
424 | 424 | * Private functions |
425 | 425 | */ |
426 | - public function test_isValidKeyValid(){} |
|
427 | - public function test_isValidKeyInvalid(){} |
|
428 | - public function test_checkTraversableArray(){} |
|
429 | - public function test_checkTraversableTraversable(){} |
|
430 | - public function test_checkTraversableException(){} |
|
431 | - public function test_hasFailureNoFailure(){} |
|
432 | - public function test_hasFailureException(){} |
|
426 | + public function test_isValidKeyValid() {} |
|
427 | + public function test_isValidKeyInvalid() {} |
|
428 | + public function test_checkTraversableArray() {} |
|
429 | + public function test_checkTraversableTraversable() {} |
|
430 | + public function test_checkTraversableException() {} |
|
431 | + public function test_hasFailureNoFailure() {} |
|
432 | + public function test_hasFailureException() {} |
|
433 | 433 | } |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | public function set($key, $value, $ttl = null) |
38 | 38 | { |
39 | 39 | //convert to timestamp from now. |
40 | - if ($ttl instanceof \DateInterval){ |
|
40 | + if ($ttl instanceof \DateInterval) { |
|
41 | 41 | $dateTime = new \DateTime(); |
42 | - $dateTime->add( $ttl ); |
|
42 | + $dateTime->add($ttl); |
|
43 | 43 | $ttl = $dateTime->getTimestamp() - time(); |
44 | 44 | } |
45 | 45 | |
46 | - if (!is_int($ttl) || $ttl === null){ |
|
46 | + if (!is_int($ttl) || $ttl === null) { |
|
47 | 47 | throw new InvalidArgumentException('$ttl can only be an instance of \DateInterval, int or null'); |
48 | 48 | } |
49 | 49 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | { |
87 | 87 | $this->_isValidKey($key); |
88 | 88 | |
89 | - if ($this->cache->has($key)){ |
|
89 | + if ($this->cache->has($key)) { |
|
90 | 90 | return $this->cache->get($key); |
91 | 91 | } |
92 | 92 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $this->_isTraversable($keys); |
128 | 128 | $result = []; |
129 | 129 | |
130 | - foreach ((array)$keys as $key){ |
|
130 | + foreach ((array)$keys as $key) { |
|
131 | 131 | $cachedItem = $this->cache->get($key); |
132 | 132 | $result[$key] = (null !== $cachedItem) ? $cachedItem : $default; |
133 | 133 | } |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | $this->_isTraversable($values); |
156 | 156 | $results = []; |
157 | 157 | |
158 | - foreach ((array)$values as $key => $value){ |
|
158 | + foreach ((array)$values as $key => $value) { |
|
159 | 159 | $results[] = $this->cache->set($key, $value, $ttl); |
160 | 160 | } |
161 | 161 | |
162 | - if ($this->_hasFailure($results)){ |
|
162 | + if ($this->_hasFailure($results)) { |
|
163 | 163 | return false; |
164 | 164 | } |
165 | 165 | |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | $this->_isTraversable($keys); |
183 | 183 | $results = []; |
184 | 184 | |
185 | - foreach ((array)$keys as $key){ |
|
185 | + foreach ((array)$keys as $key) { |
|
186 | 186 | $results[] = $this->cache->delete($key); |
187 | 187 | } |
188 | 188 | |
189 | - if ($this->_hasFailure($results)){ |
|
189 | + if ($this->_hasFailure($results)) { |
|
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | |
@@ -209,8 +209,8 @@ discard block |
||
209 | 209 | * @param $key |
210 | 210 | * @throws InvalidArgumentException |
211 | 211 | */ |
212 | - private function _isValidKey($key){ |
|
213 | - if (!is_string($key)){ |
|
212 | + private function _isValidKey($key) { |
|
213 | + if (!is_string($key)) { |
|
214 | 214 | throw new InvalidArgumentException('provided key must be a valid string'); |
215 | 215 | } |
216 | 216 | } |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | * @return bool |
224 | 224 | * @internal |
225 | 225 | */ |
226 | - private function _isTraversable($data){ |
|
226 | + private function _isTraversable($data) { |
|
227 | 227 | |
228 | - if (is_array($data) || $data instanceof \Traversable){ |
|
228 | + if (is_array($data) || $data instanceof \Traversable) { |
|
229 | 229 | return true; |
230 | 230 | } |
231 | 231 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | private function _hasKeys(array $arr) |
241 | 241 | { |
242 | - if (array() === $arr || array_keys($arr) === range(0, count($arr) - 1)){ |
|
242 | + if (array() === $arr || array_keys($arr) === range(0, count($arr) - 1)) { |
|
243 | 243 | throw new InvalidArgumentException('Keys missing'); |
244 | 244 | } |
245 | 245 | |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * @return bool |
254 | 254 | * @internal |
255 | 255 | */ |
256 | - private function _hasFailure(array $results){ |
|
257 | - if (in_array(false, $results)){ |
|
256 | + private function _hasFailure(array $results) { |
|
257 | + if (in_array(false, $results)) { |
|
258 | 258 | return true; |
259 | 259 | } |
260 | 260 | return false; |