@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $keyword = self::PREFIX . $item->getKey(); |
81 | 81 | $v = json_encode($this->driverPreWrap($item)); |
82 | 82 | |
83 | - if (isset($this->config[ 'limited_memory_each_object' ]) && strlen($v) > $this->config[ 'limited_memory_each_object' ]) { |
|
83 | + if (isset($this->config['limited_memory_each_object']) && strlen($v) > $this->config['limited_memory_each_object']) { |
|
84 | 84 | return false; |
85 | 85 | } |
86 | 86 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | // return null if no caching |
102 | 102 | // return value if in caching |
103 | 103 | $keyword = self::PREFIX . $item->getKey(); |
104 | - $x = isset($_COOKIE[ $keyword ]) ? json_decode($_COOKIE[ $keyword ], true) : false; |
|
104 | + $x = isset($_COOKIE[$keyword]) ? json_decode($_COOKIE[$keyword], true) : false; |
|
105 | 105 | |
106 | 106 | if ($x == false) { |
107 | 107 | return null; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | { |
123 | 123 | $this->driverConnect(); |
124 | 124 | $keyword = self::PREFIX . $key; |
125 | - $x = isset($_COOKIE[ $keyword ]) ? $this->decode(json_decode($_COOKIE[ $keyword ])->t) : false; |
|
125 | + $x = isset($_COOKIE[$keyword]) ? $this->decode(json_decode($_COOKIE[$keyword])->t) : false; |
|
126 | 126 | |
127 | 127 | return $x ? $x - time() : $x; |
128 | 128 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | if ($item instanceof Item) { |
141 | 141 | $this->driverConnect(); |
142 | 142 | $keyword = self::PREFIX . $item->getKey(); |
143 | - $_COOKIE[ $keyword ] = null; |
|
143 | + $_COOKIE[$keyword] = null; |
|
144 | 144 | |
145 | 145 | return @setcookie($keyword, null, -10); |
146 | 146 | } else { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $this->driverConnect(); |
158 | 158 | foreach ($_COOKIE as $keyword => $value) { |
159 | 159 | if (strpos($keyword, self::PREFIX) !== false) { |
160 | - $_COOKIE[ $keyword ] = null; |
|
160 | + $_COOKIE[$keyword] = null; |
|
161 | 161 | $result = @setcookie($keyword, null, -10); |
162 | 162 | if ($return !== false) { |
163 | 163 | $return = $result; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function printNewLine($count = 1) |
81 | 81 | { |
82 | - for($i = 0; $i < $count; $i++){ |
|
82 | + for ($i = 0; $i < $count; $i++) { |
|
83 | 83 | print PHP_EOL; |
84 | 84 | } |
85 | 85 | |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function printText($string, $strtoupper = false) |
95 | 95 | { |
96 | - if(!$strtoupper){ |
|
96 | + if (!$strtoupper) { |
|
97 | 97 | print trim($string) . PHP_EOL; |
98 | - }else{ |
|
98 | + } else { |
|
99 | 99 | print strtoupper(trim($string) . PHP_EOL); |
100 | 100 | } |
101 | 101 |
@@ -273,7 +273,7 @@ |
||
273 | 273 | |
274 | 274 | if (!is_dir($path)) { |
275 | 275 | throw new phpFastCacheDriverException("Can't read PATH:" . $path, 94); |
276 | - }else{ |
|
276 | + } else{ |
|
277 | 277 | $size = Directory::dirSize($path); |
278 | 278 | } |
279 | 279 |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * Testing memcached as it is declared in .travis.yml |
22 | 22 | */ |
23 | -try{ |
|
23 | +try { |
|
24 | 24 | $filesInstance = CacheManager::getInstance('Files'); |
25 | 25 | $RedisInstance = CacheManager::getInstance('Redis'); |
26 | 26 | $MemcacheInstance = CacheManager::getInstance('Memcached'); |
27 | -}catch(phpFastCacheDriverCheckException $e){ |
|
27 | +} catch (phpFastCacheDriverCheckException $e) { |
|
28 | 28 | $testHelper->printSkipText($e->getMessage())->terminateTest(); |
29 | 29 | } |
30 | 30 | |
@@ -32,20 +32,20 @@ discard block |
||
32 | 32 | $actOnAll = new ActOnAll(); |
33 | 33 | $statsAry = $actOnAll->getStats(); |
34 | 34 | |
35 | -if(is_array($statsAry)){ |
|
36 | - if(count($statsAry) !== 3){ |
|
35 | +if (is_array($statsAry)) { |
|
36 | + if (count($statsAry) !== 3) { |
|
37 | 37 | $testHelper->printFailText('Wrong count of driverStatistics objects: Got ' . count($statsAry) . " element(s), expected 3"); |
38 | 38 | goto endOfTest; |
39 | 39 | } |
40 | 40 | |
41 | 41 | foreach ($statsAry as $stat) { |
42 | - if(!is_object($stat) || !($stat instanceof driverStatistic)){ |
|
42 | + if (!is_object($stat) || !($stat instanceof driverStatistic)) { |
|
43 | 43 | $testHelper->printFailText('$statsAry contains one element that is not a driverStatistic object'); |
44 | 44 | goto endOfTest; |
45 | 45 | } |
46 | 46 | } |
47 | 47 | $testHelper->printPassText('ActOnAll helper passed all tests'); |
48 | -}else{ |
|
48 | +} else { |
|
49 | 49 | $testHelper->printFailText('$statsAry is not an array'); |
50 | 50 | } |
51 | 51 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | $filesInstance = CacheManager::getInstance('Files'); |
25 | 25 | $RedisInstance = CacheManager::getInstance('Redis'); |
26 | 26 | $MemcacheInstance = CacheManager::getInstance('Memcached'); |
27 | -}catch(phpFastCacheDriverCheckException $e){ |
|
27 | +} catch(phpFastCacheDriverCheckException $e){ |
|
28 | 28 | $testHelper->printSkipText($e->getMessage())->terminateTest(); |
29 | 29 | } |
30 | 30 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | } |
46 | 46 | } |
47 | 47 | $testHelper->printPassText('ActOnAll helper passed all tests'); |
48 | -}else{ |
|
48 | +} else{ |
|
49 | 49 | $testHelper->printFailText('$statsAry is not an array'); |
50 | 50 | } |
51 | 51 |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | protected function driverConnect() |
126 | 126 | { |
127 | - $config = isset($this->config[ 'predis' ]) ? $this->config[ 'predis' ] : []; |
|
127 | + $config = isset($this->config['predis']) ? $this->config['predis'] : []; |
|
128 | 128 | |
129 | 129 | $this->instance = new PredisClient(array_merge([ |
130 | 130 | 'host' => '127.0.0.1', |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $info = $this->instance->info(); |
151 | 151 | $size = (isset($info['Memory']['used_memory']) ? $info['Memory']['used_memory'] : 0); |
152 | 152 | $version = (isset($info['Server']['redis_version']) ? $info['Server']['redis_version'] : 0); |
153 | - $date = (isset($info['Server'][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info['Server'][ 'uptime_in_seconds' ]) : 'unknown date'); |
|
153 | + $date = (isset($info['Server']['uptime_in_seconds']) ? (new \DateTime())->setTimestamp(time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
154 | 154 | |
155 | 155 | return (new driverStatistic()) |
156 | 156 | ->setData(implode(', ', array_keys($this->itemInstances))) |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | $config = isset($this->config[ 'predis' ]) ? $this->config[ 'predis' ] : []; |
126 | 126 | |
127 | 127 | $this->instance = new PredisClient(array_merge([ |
128 | - 'host' => '127.0.0.1', |
|
129 | - 'port' => 6379, |
|
130 | - 'password' => null, |
|
131 | - 'database' => null, |
|
128 | + 'host' => '127.0.0.1', |
|
129 | + 'port' => 6379, |
|
130 | + 'password' => null, |
|
131 | + 'database' => null, |
|
132 | 132 | ], $config)); |
133 | 133 | |
134 | 134 | return true; |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | $date = (isset($info['Server'][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info['Server'][ 'uptime_in_seconds' ]) : 'unknown date'); |
152 | 152 | |
153 | 153 | return (new driverStatistic()) |
154 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
155 | - ->setRawData($info) |
|
156 | - ->setSize($size) |
|
157 | - ->setInfo(sprintf("The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", $version, $date->format(DATE_RFC2822))); |
|
154 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
155 | + ->setRawData($info) |
|
156 | + ->setSize($size) |
|
157 | + ->setInfo(sprintf("The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", $version, $date->format(DATE_RFC2822))); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | \ No newline at end of file |
@@ -19,28 +19,28 @@ |
||
19 | 19 | try { |
20 | 20 | $driverInstance->getItem('test{test'); |
21 | 21 | $testHelper->printFailText('1/4 An unsupported key character did not get caught by regular expression'); |
22 | -}catch(phpFastCacheInvalidArgumentException $e){ |
|
22 | +} catch (phpFastCacheInvalidArgumentException $e) { |
|
23 | 23 | $testHelper->printPassText('1/4 An unsupported key character has been caught by regular expression'); |
24 | 24 | } |
25 | 25 | |
26 | 26 | try { |
27 | 27 | $driverInstance->getItem(':testtest'); |
28 | 28 | $testHelper->printFailText('2/4 An unsupported key character did not get caught by regular expression'); |
29 | -}catch(phpFastCacheInvalidArgumentException $e){ |
|
29 | +} catch (phpFastCacheInvalidArgumentException $e) { |
|
30 | 30 | $testHelper->printPassText('2/4 An unsupported key character has been caught by regular expression'); |
31 | 31 | } |
32 | 32 | |
33 | 33 | try { |
34 | 34 | $driverInstance->getItem('testtest}'); |
35 | 35 | $testHelper->printFailText('3/4 An unsupported key character did not get caught by regular expression'); |
36 | -}catch(phpFastCacheInvalidArgumentException $e){ |
|
36 | +} catch (phpFastCacheInvalidArgumentException $e) { |
|
37 | 37 | $testHelper->printPassText('3/4 An unsupported key character has been caught by regular expression'); |
38 | 38 | } |
39 | 39 | |
40 | 40 | try { |
41 | 41 | $driverInstance->getItem('testtest'); |
42 | 42 | $testHelper->printPassText('4/4 No exception caught while trying with a key without unsupported character'); |
43 | -}catch(phpFastCacheInvalidArgumentException $e){ |
|
43 | +} catch (phpFastCacheInvalidArgumentException $e) { |
|
44 | 44 | $testHelper->printFailText('4/4 An exception has been caught while trying with a key without unsupported character'); |
45 | 45 | } |
46 | 46 |
@@ -19,28 +19,28 @@ |
||
19 | 19 | try { |
20 | 20 | $driverInstance->getItem('test{test'); |
21 | 21 | $testHelper->printFailText('1/4 An unsupported key character did not get caught by regular expression'); |
22 | -}catch(phpFastCacheInvalidArgumentException $e){ |
|
22 | +} catch(phpFastCacheInvalidArgumentException $e){ |
|
23 | 23 | $testHelper->printPassText('1/4 An unsupported key character has been caught by regular expression'); |
24 | 24 | } |
25 | 25 | |
26 | 26 | try { |
27 | 27 | $driverInstance->getItem(':testtest'); |
28 | 28 | $testHelper->printFailText('2/4 An unsupported key character did not get caught by regular expression'); |
29 | -}catch(phpFastCacheInvalidArgumentException $e){ |
|
29 | +} catch(phpFastCacheInvalidArgumentException $e){ |
|
30 | 30 | $testHelper->printPassText('2/4 An unsupported key character has been caught by regular expression'); |
31 | 31 | } |
32 | 32 | |
33 | 33 | try { |
34 | 34 | $driverInstance->getItem('testtest}'); |
35 | 35 | $testHelper->printFailText('3/4 An unsupported key character did not get caught by regular expression'); |
36 | -}catch(phpFastCacheInvalidArgumentException $e){ |
|
36 | +} catch(phpFastCacheInvalidArgumentException $e){ |
|
37 | 37 | $testHelper->printPassText('3/4 An unsupported key character has been caught by regular expression'); |
38 | 38 | } |
39 | 39 | |
40 | 40 | try { |
41 | 41 | $driverInstance->getItem('testtest'); |
42 | 42 | $testHelper->printPassText('4/4 No exception caught while trying with a key without unsupported character'); |
43 | -}catch(phpFastCacheInvalidArgumentException $e){ |
|
43 | +} catch(phpFastCacheInvalidArgumentException $e){ |
|
44 | 44 | $testHelper->printFailText('4/4 An exception has been caught while trying with a key without unsupported character'); |
45 | 45 | } |
46 | 46 |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | |
44 | 44 | $testHelper->printNewLine()->printText('Setting up value to "test-key, test-key2, test-key3"...')->printNewLine(); |
45 | 45 | $Psr16Adapter->setMultiple([ |
46 | - 'test-key' => $value, |
|
47 | - 'test-key2' => $value, |
|
48 | - 'test-key3' => $value |
|
46 | + 'test-key' => $value, |
|
47 | + 'test-key2' => $value, |
|
48 | + 'test-key3' => $value |
|
49 | 49 | ]); |
50 | 50 | |
51 | 51 | |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | |
62 | 62 | $testHelper->printNewLine()->printText('Setting up value to "test-key, test-key2, test-key3"...')->printNewLine(); |
63 | 63 | $Psr16Adapter->setMultiple([ |
64 | - 'test-key' => $value, |
|
65 | - 'test-key2' => $value, |
|
66 | - 'test-key3' => $value |
|
64 | + 'test-key' => $value, |
|
65 | + 'test-key2' => $value, |
|
66 | + 'test-key3' => $value |
|
67 | 67 | ]); |
68 | 68 | |
69 | 69 | if($Psr16Adapter->has('test-key') && $Psr16Adapter->has('test-key2') && $Psr16Adapter->has('test-key3')){ |
@@ -17,27 +17,27 @@ discard block |
||
17 | 17 | |
18 | 18 | $value = str_shuffle(uniqid('pfc', true)); |
19 | 19 | |
20 | -if(!$Psr16Adapter->has('test-key')){ |
|
20 | +if (!$Psr16Adapter->has('test-key')) { |
|
21 | 21 | $testHelper->printPassText('1/6 Psr16 hasser returned expected boolean (false)'); |
22 | -}else{ |
|
22 | +} else { |
|
23 | 23 | $testHelper->printFailText('1/6 Psr16 hasser returned unexpected boolean (true)'); |
24 | 24 | } |
25 | 25 | |
26 | 26 | $testHelper->printNewLine()->printText('Setting up value to "test-key"...')->printNewLine(); |
27 | 27 | $Psr16Adapter->set('test-key', $value); |
28 | 28 | |
29 | -if($Psr16Adapter->get('test-key') === $value){ |
|
29 | +if ($Psr16Adapter->get('test-key') === $value) { |
|
30 | 30 | $testHelper->printPassText('2/6 Psr16 getter returned expected value: ' . $value); |
31 | -}else{ |
|
31 | +} else { |
|
32 | 32 | $testHelper->printFailText('2/6 Psr16 getter returned unexpected value: ' . $value); |
33 | 33 | } |
34 | 34 | |
35 | 35 | $testHelper->printNewLine()->printText('Deleting key "test-key"...')->printNewLine(); |
36 | 36 | $Psr16Adapter->delete('test-key', $value); |
37 | 37 | |
38 | -if(!$Psr16Adapter->has('test-key')){ |
|
38 | +if (!$Psr16Adapter->has('test-key')) { |
|
39 | 39 | $testHelper->printPassText('3/6 Psr16 hasser returned expected boolean (false)'); |
40 | -}else{ |
|
40 | +} else { |
|
41 | 41 | $testHelper->printFailText('3/6 Psr16 hasser returned unexpected boolean (true)'); |
42 | 42 | } |
43 | 43 | |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | |
52 | 52 | $values = $Psr16Adapter->getMultiple(['test-key', 'test-key2', 'test-key3']); |
53 | -if(count(array_filter($values)) === 3){ |
|
53 | +if (count(array_filter($values)) === 3) { |
|
54 | 54 | $testHelper->printPassText('4/6 Psr16 multiple getters returned expected values (3)'); |
55 | -}else{ |
|
55 | +} else { |
|
56 | 56 | $testHelper->printFailText('4/6 Psr16 getters(3) returned unexpected values.'); |
57 | 57 | } |
58 | 58 | |
@@ -66,18 +66,18 @@ discard block |
||
66 | 66 | 'test-key3' => $value |
67 | 67 | ]); |
68 | 68 | |
69 | -if($Psr16Adapter->has('test-key') && $Psr16Adapter->has('test-key2') && $Psr16Adapter->has('test-key3')){ |
|
69 | +if ($Psr16Adapter->has('test-key') && $Psr16Adapter->has('test-key2') && $Psr16Adapter->has('test-key3')) { |
|
70 | 70 | $testHelper->printPassText('5/6 Psr16 hasser returned expected booleans (true)'); |
71 | -}else{ |
|
71 | +} else { |
|
72 | 72 | $testHelper->printFailText('5/6 Psr16 hasser returned one or more unexpected boolean (false)'); |
73 | 73 | } |
74 | 74 | |
75 | 75 | $testHelper->printNewLine()->printText('Deleting up keys "test-key, test-key2, test-key3"...')->printNewLine(); |
76 | 76 | $Psr16Adapter->deleteMultiple(['test-key', 'test-key2', 'test-key3']); |
77 | 77 | |
78 | -if(!$Psr16Adapter->has('test-key') && !$Psr16Adapter->has('test-key2') && !$Psr16Adapter->has('test-key3')){ |
|
78 | +if (!$Psr16Adapter->has('test-key') && !$Psr16Adapter->has('test-key2') && !$Psr16Adapter->has('test-key3')) { |
|
79 | 79 | $testHelper->printPassText('6/6 Psr16 hasser returned expected booleans (false)'); |
80 | -}else{ |
|
80 | +} else { |
|
81 | 81 | $testHelper->printFailText('6/6 Psr16 hasser returned one or more unexpected boolean (true)'); |
82 | 82 | } |
83 | 83 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | if(!$Psr16Adapter->has('test-key')){ |
21 | 21 | $testHelper->printPassText('1/6 Psr16 hasser returned expected boolean (false)'); |
22 | -}else{ |
|
22 | +} else{ |
|
23 | 23 | $testHelper->printFailText('1/6 Psr16 hasser returned unexpected boolean (true)'); |
24 | 24 | } |
25 | 25 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | if($Psr16Adapter->get('test-key') === $value){ |
30 | 30 | $testHelper->printPassText('2/6 Psr16 getter returned expected value: ' . $value); |
31 | -}else{ |
|
31 | +} else{ |
|
32 | 32 | $testHelper->printFailText('2/6 Psr16 getter returned unexpected value: ' . $value); |
33 | 33 | } |
34 | 34 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | if(!$Psr16Adapter->has('test-key')){ |
39 | 39 | $testHelper->printPassText('3/6 Psr16 hasser returned expected boolean (false)'); |
40 | -}else{ |
|
40 | +} else{ |
|
41 | 41 | $testHelper->printFailText('3/6 Psr16 hasser returned unexpected boolean (true)'); |
42 | 42 | } |
43 | 43 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $values = $Psr16Adapter->getMultiple(['test-key', 'test-key2', 'test-key3']); |
53 | 53 | if(count(array_filter($values)) === 3){ |
54 | 54 | $testHelper->printPassText('4/6 Psr16 multiple getters returned expected values (3)'); |
55 | -}else{ |
|
55 | +} else{ |
|
56 | 56 | $testHelper->printFailText('4/6 Psr16 getters(3) returned unexpected values.'); |
57 | 57 | } |
58 | 58 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | if($Psr16Adapter->has('test-key') && $Psr16Adapter->has('test-key2') && $Psr16Adapter->has('test-key3')){ |
70 | 70 | $testHelper->printPassText('5/6 Psr16 hasser returned expected booleans (true)'); |
71 | -}else{ |
|
71 | +} else{ |
|
72 | 72 | $testHelper->printFailText('5/6 Psr16 hasser returned one or more unexpected boolean (false)'); |
73 | 73 | } |
74 | 74 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | if(!$Psr16Adapter->has('test-key') && !$Psr16Adapter->has('test-key2') && !$Psr16Adapter->has('test-key3')){ |
79 | 79 | $testHelper->printPassText('6/6 Psr16 hasser returned expected booleans (false)'); |
80 | -}else{ |
|
80 | +} else{ |
|
81 | 81 | $testHelper->printFailText('6/6 Psr16 hasser returned one or more unexpected boolean (true)'); |
82 | 82 | } |
83 | 83 |
@@ -63,8 +63,8 @@ |
||
63 | 63 | { |
64 | 64 | try { |
65 | 65 | $cacheItem = $this->internalCacheInstance |
66 | - ->getItem($key) |
|
67 | - ->set($value); |
|
66 | + ->getItem($key) |
|
67 | + ->set($value); |
|
68 | 68 | if (is_int($ttl) || $ttl instanceof \DateInterval) { |
69 | 69 | $cacheItem->expiresAfter($ttl); |
70 | 70 | } |
@@ -110,7 +110,7 @@ |
||
110 | 110 | public function getMultiple($keys, $default = null) |
111 | 111 | { |
112 | 112 | try { |
113 | - return array_map(function (ExtendedCacheItemInterface $item) { |
|
113 | + return array_map(function(ExtendedCacheItemInterface $item) { |
|
114 | 114 | return $item->get(); |
115 | 115 | }, $this->internalCacheInstance->getItems($keys)); |
116 | 116 | } catch (phpFastCacheInvalidArgumentException $e) { |