@@ -28,36 +28,36 @@ |
||
| 28 | 28 | $item3 = $driverInstance->getItem('tag-test3'); |
| 29 | 29 | |
| 30 | 30 | $item1->set('item-test_1') |
| 31 | - ->expiresAfter(600) |
|
| 32 | - ->addTag('tag-test_1') |
|
| 33 | - ->addTag('tag-test_all') |
|
| 34 | - ->addTag('tag-test_all2') |
|
| 35 | - ->addTag('tag-test_all3'); |
|
| 31 | + ->expiresAfter(600) |
|
| 32 | + ->addTag('tag-test_1') |
|
| 33 | + ->addTag('tag-test_all') |
|
| 34 | + ->addTag('tag-test_all2') |
|
| 35 | + ->addTag('tag-test_all3'); |
|
| 36 | 36 | |
| 37 | 37 | $item2->set('item-test_2') |
| 38 | - ->expiresAfter(600) |
|
| 39 | - ->addTag('tag-test_1') |
|
| 40 | - ->addTag('tag-test_2') |
|
| 41 | - ->addTag('tag-test_all') |
|
| 42 | - ->addTag('tag-test_all2') |
|
| 43 | - ->addTag('tag-test_all3'); |
|
| 38 | + ->expiresAfter(600) |
|
| 39 | + ->addTag('tag-test_1') |
|
| 40 | + ->addTag('tag-test_2') |
|
| 41 | + ->addTag('tag-test_all') |
|
| 42 | + ->addTag('tag-test_all2') |
|
| 43 | + ->addTag('tag-test_all3'); |
|
| 44 | 44 | |
| 45 | 45 | $item3->set('item-test_3') |
| 46 | - ->expiresAfter(600) |
|
| 47 | - ->addTag('tag-test_1') |
|
| 48 | - ->addTag('tag-test_2') |
|
| 49 | - ->addTag('tag-test_3') |
|
| 50 | - ->addTag('tag-test_all') |
|
| 51 | - ->addTag('tag-test_all2') |
|
| 52 | - ->addTag('tag-test_all3') |
|
| 53 | - ->addTag('tag-test_all4'); |
|
| 46 | + ->expiresAfter(600) |
|
| 47 | + ->addTag('tag-test_1') |
|
| 48 | + ->addTag('tag-test_2') |
|
| 49 | + ->addTag('tag-test_3') |
|
| 50 | + ->addTag('tag-test_all') |
|
| 51 | + ->addTag('tag-test_all2') |
|
| 52 | + ->addTag('tag-test_all3') |
|
| 53 | + ->addTag('tag-test_all4'); |
|
| 54 | 54 | |
| 55 | 55 | $driverInstance->saveMultiple($item1, $item2, $item3); |
| 56 | 56 | |
| 57 | 57 | return [ |
| 58 | - 'item1' => $item1, |
|
| 59 | - 'item2' => $item2, |
|
| 60 | - 'item3' => $item3 |
|
| 58 | + 'item1' => $item1, |
|
| 59 | + 'item2' => $item2, |
|
| 60 | + 'item3' => $item3 |
|
| 61 | 61 | ]; |
| 62 | 62 | }; |
| 63 | 63 | |
@@ -82,15 +82,13 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | echo "[PASS] STEP#1 // Successfully retrieved 3 tagged item keys\n"; |
| 85 | - } |
|
| 86 | - else |
|
| 85 | + } else |
|
| 87 | 86 | { |
| 88 | 87 | echo '[FAIL] STEP#1 //Got wrong count of item:' . count($tagsItems) . "\n"; |
| 89 | 88 | $status = 1; |
| 90 | 89 | goto itemTagTest2; |
| 91 | 90 | } |
| 92 | -} |
|
| 93 | -else |
|
| 91 | +} else |
|
| 94 | 92 | { |
| 95 | 93 | echo '[FAIL] STEP#1 // Expected $tagsItems to be an array, got: ' . gettype($tagsItems) . "\n"; |
| 96 | 94 | $status = 1; |
@@ -120,15 +118,13 @@ discard block |
||
| 120 | 118 | } |
| 121 | 119 | } |
| 122 | 120 | echo "[PASS] STEP#2 // Successfully retrieved 3 tagged item key\n"; |
| 123 | - } |
|
| 124 | - else |
|
| 121 | + } else |
|
| 125 | 122 | { |
| 126 | 123 | echo '[FAIL] STEP#2 // Got wrong count of item:' . count($tagsItems) . "\n"; |
| 127 | 124 | $status = 1; |
| 128 | 125 | goto itemTagTest3; |
| 129 | 126 | } |
| 130 | -} |
|
| 131 | -else |
|
| 127 | +} else |
|
| 132 | 128 | { |
| 133 | 129 | echo '[FAIL] STEP#2 // Expected $tagsItems to be an array, got: ' . gettype($tagsItems) . "\n"; |
| 134 | 130 | $status = 1; |
@@ -157,22 +153,19 @@ discard block |
||
| 157 | 153 | goto itemTagTest4; |
| 158 | 154 | } |
| 159 | 155 | echo "[PASS] STEP#3 // Successfully retrieved 1 tagged item keys\n"; |
| 160 | - } |
|
| 161 | - else |
|
| 156 | + } else |
|
| 162 | 157 | { |
| 163 | 158 | echo '[FAIL] STEP#3 // Got wrong array key, expected "tag-test3", got "' . key($tagsItems) . "\"\n"; |
| 164 | 159 | $status = 1; |
| 165 | 160 | goto itemTagTest4; |
| 166 | 161 | } |
| 167 | - } |
|
| 168 | - else |
|
| 162 | + } else |
|
| 169 | 163 | { |
| 170 | 164 | echo '[FAIL] STEP#3 // Got wrong count of item:' . count($tagsItems) . "\n"; |
| 171 | 165 | $status = 1; |
| 172 | 166 | goto itemTagTest4; |
| 173 | 167 | } |
| 174 | -} |
|
| 175 | -else |
|
| 168 | +} else |
|
| 176 | 169 | { |
| 177 | 170 | echo '[FAIL] STEP#3 // Expected $tagsItems to be an array, got: ' . gettype($tagsItems) . "\n"; |
| 178 | 171 | $status = 1; |
@@ -192,8 +185,7 @@ discard block |
||
| 192 | 185 | { |
| 193 | 186 | echo "[FAIL] STEP#4 // Getter getItemsByTag() found item(s), possible memory leak \n"; |
| 194 | 187 | $status = 1; |
| 195 | -} |
|
| 196 | -else |
|
| 188 | +} else |
|
| 197 | 189 | { |
| 198 | 190 | echo "[PASS] STEP#4 // Getter getItemsByTag() found no item \n"; |
| 199 | 191 | } |
@@ -205,8 +197,7 @@ discard block |
||
| 205 | 197 | { |
| 206 | 198 | echo "[FAIL] STEP#4 // Item 'tag-test{$i}' should've been deleted and is still in cache storage \n"; |
| 207 | 199 | $status = 1; |
| 208 | - } |
|
| 209 | - else |
|
| 200 | + } else |
|
| 210 | 201 | { |
| 211 | 202 | echo "[PASS] STEP#4 // Item 'tag-test{$i}' have been deleted and is no longer in cache storage \n"; |
| 212 | 203 | } |
@@ -226,8 +217,7 @@ discard block |
||
| 226 | 217 | { |
| 227 | 218 | echo "[FAIL] STEP#5 // Getter getItemsByTag() found item(s), possible memory leak \n"; |
| 228 | 219 | $status = 1; |
| 229 | -} |
|
| 230 | -else |
|
| 220 | +} else |
|
| 231 | 221 | { |
| 232 | 222 | echo "[PASS] STEP#5 // Getter getItemsByTag() found no item \n"; |
| 233 | 223 | } |
@@ -239,8 +229,7 @@ discard block |
||
| 239 | 229 | { |
| 240 | 230 | echo "[FAIL] STEP#5 // Item 'tag-test{$i}' should've been deleted and is still in cache storage \n"; |
| 241 | 231 | $status = 1; |
| 242 | - } |
|
| 243 | - else |
|
| 232 | + } else |
|
| 244 | 233 | { |
| 245 | 234 | echo "[PASS] STEP#5 // Item 'tag-test{$i}' have been deleted and is no longer in cache storage \n"; |
| 246 | 235 | } |
@@ -263,8 +252,7 @@ discard block |
||
| 263 | 252 | { |
| 264 | 253 | echo "[FAIL] STEP#6 // Getter getItem() found item 'item-test_3', possible memory leak \n"; |
| 265 | 254 | $status = 1; |
| 266 | -} |
|
| 267 | -else |
|
| 255 | +} else |
|
| 268 | 256 | { |
| 269 | 257 | echo "[PASS] STEP#6 // Getter getItem() did not found item 'item-test_3' \n"; |
| 270 | 258 | } |
@@ -285,8 +273,7 @@ discard block |
||
| 285 | 273 | { |
| 286 | 274 | echo "[FAIL] STEP#7 // Item '{$item->getKey()}' does not have the string part '{$appendStr}' in it's value \n"; |
| 287 | 275 | $status = 1; |
| 288 | - } |
|
| 289 | - else |
|
| 276 | + } else |
|
| 290 | 277 | { |
| 291 | 278 | echo "[PASS] STEP#7 // Item 'tag-test{$item->getKey()}' does have the string part '{$appendStr}' in it's value \n"; |
| 292 | 279 | } |
@@ -308,8 +295,7 @@ discard block |
||
| 308 | 295 | { |
| 309 | 296 | echo "[FAIL] STEP#7 // Item '{$item->getKey()}' does not have the string part '{$prependStr}' in it's value \n"; |
| 310 | 297 | $status = 1; |
| 311 | - } |
|
| 312 | - else |
|
| 298 | + } else |
|
| 313 | 299 | { |
| 314 | 300 | echo "[PASS] STEP#7 // Item 'tag-test{$item->getKey()}' does have the string part '{$prependStr}' in it's value \n"; |
| 315 | 301 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | chdir(__DIR__); |
| 12 | 12 | require_once __DIR__ . '/../src/autoload.php'; |
| 13 | 13 | $testHelper = new TestHelper('Items tags features'); |
| 14 | -$defaultDriver = (!empty($argv[ 1 ]) ? ucfirst($argv[ 1 ]) : 'Files'); |
|
| 14 | +$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files'); |
|
| 15 | 15 | $driverInstance = CacheManager::getInstance($defaultDriver); |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | $createItemsCallback(); |
| 66 | 66 | |
| 67 | 67 | $tagsItems = $driverInstance->getItemsByTag('tag-test_all'); |
| 68 | -if(is_array($tagsItems)) |
|
| 68 | +if (is_array($tagsItems)) |
|
| 69 | 69 | { |
| 70 | - if(count($tagsItems) === 3) |
|
| 70 | + if (count($tagsItems) === 3) |
|
| 71 | 71 | { |
| 72 | - foreach($tagsItems as $tagsItem) |
|
| 72 | + foreach ($tagsItems as $tagsItem) |
|
| 73 | 73 | { |
| 74 | - if(!in_array($tagsItem->getKey(), ['tag-test1', 'tag-test2', 'tag-test3'])){ |
|
| 74 | + if (!in_array($tagsItem->getKey(), ['tag-test1', 'tag-test2', 'tag-test3'])) { |
|
| 75 | 75 | $testHelper->printFailText('STEP#1 // Got unexpected tagged item key:' . $tagsItem->getKey()); |
| 76 | 76 | goto itemTagTest2; |
| 77 | 77 | } |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | $tagsItems = $driverInstance->getItemsByTagsAll(['tag-test_all', 'tag-test_all2', 'tag-test_all3']); |
| 102 | 102 | |
| 103 | -if(is_array($tagsItems)) |
|
| 103 | +if (is_array($tagsItems)) |
|
| 104 | 104 | { |
| 105 | - if(count($tagsItems) === 3) |
|
| 105 | + if (count($tagsItems) === 3) |
|
| 106 | 106 | { |
| 107 | - foreach($tagsItems as $tagsItem) |
|
| 107 | + foreach ($tagsItems as $tagsItem) |
|
| 108 | 108 | { |
| 109 | - if(!in_array($tagsItem->getKey(), ['tag-test1', 'tag-test2', 'tag-test3'])){ |
|
| 109 | + if (!in_array($tagsItem->getKey(), ['tag-test1', 'tag-test2', 'tag-test3'])) { |
|
| 110 | 110 | $testHelper->printFailText('STEP#2 // Got unexpected tagged item key:' . $tagsItem->getKey()); |
| 111 | 111 | goto itemTagTest3; |
| 112 | 112 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | else |
| 117 | 117 | { |
| 118 | - $testHelper->printFailText('STEP#2 // Got wrong count of item:' . count($tagsItems) ); |
|
| 118 | + $testHelper->printFailText('STEP#2 // Got wrong count of item:' . count($tagsItems)); |
|
| 119 | 119 | goto itemTagTest3; |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -135,13 +135,13 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | $tagsItems = $driverInstance->getItemsByTagsAll(['tag-test_all', 'tag-test_all2', 'tag-test_all3', 'tag-test_all4']); |
| 137 | 137 | |
| 138 | -if(is_array($tagsItems)) |
|
| 138 | +if (is_array($tagsItems)) |
|
| 139 | 139 | { |
| 140 | - if(count($tagsItems) === 1) |
|
| 140 | + if (count($tagsItems) === 1) |
|
| 141 | 141 | { |
| 142 | - if(isset($tagsItems['tag-test3'])) |
|
| 142 | + if (isset($tagsItems['tag-test3'])) |
|
| 143 | 143 | { |
| 144 | - if($tagsItems['tag-test3']->getKey() !== 'tag-test3'){ |
|
| 144 | + if ($tagsItems['tag-test3']->getKey() !== 'tag-test3') { |
|
| 145 | 145 | $testHelper->printFailText('STEP#3 // Got unexpected tagged item key:' . $tagsItems['tag-test3']->getKey()); |
| 146 | 146 | goto itemTagTest4; |
| 147 | 147 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | $createItemsCallback(); |
| 175 | 175 | $driverInstance->deleteItemsByTag('tag-test_all'); |
| 176 | 176 | |
| 177 | -if(count($driverInstance->getItemsByTag('tag-test_all')) > 0) |
|
| 177 | +if (count($driverInstance->getItemsByTag('tag-test_all')) > 0) |
|
| 178 | 178 | { |
| 179 | 179 | $testHelper->printFailText('[FAIL] STEP#4 // Getter getItemsByTag() found item(s), possible memory leak'); |
| 180 | 180 | } |
@@ -184,9 +184,9 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | $i = 0; |
| 187 | -while(++$i <= 3) |
|
| 187 | +while (++$i <= 3) |
|
| 188 | 188 | { |
| 189 | - if($driverInstance->getItem("tag-test{$i}")->isHit()) |
|
| 189 | + if ($driverInstance->getItem("tag-test{$i}")->isHit()) |
|
| 190 | 190 | { |
| 191 | 191 | $testHelper->printFailText("STEP#4 // Item 'tag-test{$i}' should've been deleted and is still in cache storage"); |
| 192 | 192 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | $driverInstance->deleteItemsByTagsAll(['tag-test_all', 'tag-test_all2', 'tag-test_all3']); |
| 208 | 208 | |
| 209 | -if(count($driverInstance->getItemsByTag('tag-test_all')) > 0) |
|
| 209 | +if (count($driverInstance->getItemsByTag('tag-test_all')) > 0) |
|
| 210 | 210 | { |
| 211 | 211 | $testHelper->printFailText('STEP#5 // Getter getItemsByTag() found item(s), possible memory leak'); |
| 212 | 212 | } |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | $i = 0; |
| 219 | -while(++$i <= 3) |
|
| 219 | +while (++$i <= 3) |
|
| 220 | 220 | { |
| 221 | - if($driverInstance->getItem("tag-test{$i}")->isHit()) |
|
| 221 | + if ($driverInstance->getItem("tag-test{$i}")->isHit()) |
|
| 222 | 222 | { |
| 223 | 223 | $testHelper->printFailText("STEP#5 // Item 'tag-test{$i}' should've been deleted and is still in cache storage"); |
| 224 | 224 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | $driverInstance->deleteItemsByTagsAll(['tag-test_all', 'tag-test_all2', 'tag-test_all3', 'tag-test_all4']); |
| 243 | 243 | |
| 244 | -if($driverInstance->getItem('item-test_3')->isHit()) |
|
| 244 | +if ($driverInstance->getItem('item-test_3')->isHit()) |
|
| 245 | 245 | { |
| 246 | 246 | $testHelper->printFailText('STEP#6 // Getter getItem() found item \'item-test_3\', possible memory leak'); |
| 247 | 247 | } |
@@ -260,9 +260,9 @@ discard block |
||
| 260 | 260 | $appendStr = '$*#*$'; |
| 261 | 261 | $driverInstance->appendItemsByTagsAll(['tag-test_all', 'tag-test_all2', 'tag-test_all3'], $appendStr); |
| 262 | 262 | |
| 263 | -foreach($driverInstance->getItems(['tag-test1', 'tag-test2', 'tag-test3']) as $item) |
|
| 263 | +foreach ($driverInstance->getItems(['tag-test1', 'tag-test2', 'tag-test3']) as $item) |
|
| 264 | 264 | { |
| 265 | - if(strpos($item->get(), $appendStr) === false) |
|
| 265 | + if (strpos($item->get(), $appendStr) === false) |
|
| 266 | 266 | { |
| 267 | 267 | $testHelper->printFailText("STEP#7 // Item '{$item->getKey()}' does not have the string part '{$appendStr}' in it's value"); |
| 268 | 268 | } |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | $prependStr = '&+_+&'; |
| 283 | 283 | $driverInstance->prependItemsByTagsAll(['tag-test_all', 'tag-test_all2', 'tag-test_all3'], $prependStr); |
| 284 | 284 | |
| 285 | -foreach($driverInstance->getItems(['tag-test1', 'tag-test2', 'tag-test3']) as $item) |
|
| 285 | +foreach ($driverInstance->getItems(['tag-test1', 'tag-test2', 'tag-test3']) as $item) |
|
| 286 | 286 | { |
| 287 | - if(strpos($item->get(), $prependStr) === false) |
|
| 287 | + if (strpos($item->get(), $prependStr) === false) |
|
| 288 | 288 | { |
| 289 | 289 | $testHelper->printFailText("STEP#8 // Item '{$item->getKey()}' does not have the string part '{$prependStr}' in it's value"); |
| 290 | 290 | } |
@@ -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; |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | $config = isset($this->config[ 'redis' ]) ? $this->config[ 'redis' ] : []; |
| 126 | 126 | |
| 127 | 127 | $this->instance = new PredisClient(array_merge([ |
| 128 | - 'host' => '127.0.0.1', |
|
| 129 | - 'port' => '6379', |
|
| 130 | - 'password' => '', |
|
| 131 | - 'database' => '', |
|
| 128 | + 'host' => '127.0.0.1', |
|
| 129 | + 'port' => '6379', |
|
| 130 | + 'password' => '', |
|
| 131 | + 'database' => '', |
|
| 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($this->instance->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($this->instance->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 |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | protected function driverConnect() |
| 124 | 124 | { |
| 125 | - $config = isset($this->config[ 'redis' ]) ? $this->config[ 'redis' ] : []; |
|
| 125 | + $config = isset($this->config['redis']) ? $this->config['redis'] : []; |
|
| 126 | 126 | |
| 127 | 127 | $this->instance = new PredisClient(array_merge([ |
| 128 | 128 | 'host' => '127.0.0.1', |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $info = $this->instance->info(); |
| 149 | 149 | $size = (isset($info['Memory']['used_memory']) ? $info['Memory']['used_memory'] : 0); |
| 150 | 150 | $version = (isset($info['Server']['redis_version']) ? $info['Server']['redis_version'] : 0); |
| 151 | - $date = (isset($info['Server'][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info['Server'][ 'uptime_in_seconds' ]) : 'unknown date'); |
|
| 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 | 154 | ->setData(implode(', ', array_keys($this->itemInstances))) |
@@ -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 | |