@@ -38,6 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @inheritdoc |
41 | + * @param string $tagName |
|
41 | 42 | */ |
42 | 43 | public function getItemsByTag($tagName) |
43 | 44 | { |
@@ -408,7 +409,7 @@ discard block |
||
408 | 409 | |
409 | 410 | /** |
410 | 411 | * @internal This method de-register an item from $this->itemInstances |
411 | - * @param CacheItemInterface|string $item |
|
412 | + * @param CacheItemInterface $item |
|
412 | 413 | * @throws phpFastCacheInvalidArgumentException |
413 | 414 | */ |
414 | 415 | protected function deregisterItem($item) |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function getItemsAsJsonString(array $keys = [], $option = 0, $depth = 512) |
32 | 32 | { |
33 | - $callback = function (CacheItemInterface $item) { |
|
33 | + $callback = function(CacheItemInterface $item) { |
|
34 | 34 | return $item->get(); |
35 | 35 | }; |
36 | 36 | return json_encode(array_map($callback, array_values($this->getItems($keys))), $option, $depth); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | if (is_string($tagName)) { |
45 | 45 | $driverResponse = $this->getItem($this->getTagKey($tagName)); |
46 | 46 | if ($driverResponse->isHit()) { |
47 | - $items = (array)$driverResponse->get(); |
|
47 | + $items = (array) $driverResponse->get(); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * getItems() may provides expired item(s) |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * #headache |
58 | 58 | */ |
59 | - return array_filter($this->getItems(array_unique(array_keys($items))), function (ExtendedCacheItemInterface $item) { |
|
59 | + return array_filter($this->getItems(array_unique(array_keys($items))), function(ExtendedCacheItemInterface $item) { |
|
60 | 60 | return $item->isHit(); |
61 | 61 | }); |
62 | 62 | } else { |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | foreach ($items as $key => $item) { |
96 | 96 | if (array_diff($tagNames, $item->getTags())) { |
97 | - unset($items[ $key ]); |
|
97 | + unset($items[$key]); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function getItemsByTagsAsJsonString(array $tagNames, $option = 0, $depth = 512) |
109 | 109 | { |
110 | - $callback = function (CacheItemInterface $item) { |
|
110 | + $callback = function(CacheItemInterface $item) { |
|
111 | 111 | return $item->get(); |
112 | 112 | }; |
113 | 113 | |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | */ |
379 | 379 | public function detachItem(CacheItemInterface $item) |
380 | 380 | { |
381 | - if (isset($this->itemInstances[ $item->getKey() ])) { |
|
381 | + if (isset($this->itemInstances[$item->getKey()])) { |
|
382 | 382 | $this->deregisterItem($item); |
383 | 383 | } |
384 | 384 | } |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | */ |
399 | 399 | public function attachItem(CacheItemInterface $item) |
400 | 400 | { |
401 | - if (isset($this->itemInstances[ $item->getKey() ]) && spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])) { |
|
401 | + if (isset($this->itemInstances[$item->getKey()]) && spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
402 | 402 | throw new phpFastCacheLogicException('The item already exists and cannot be overwritten because the Spl object hash mismatches ! You probably tried to re-attach a detached item which has been already retrieved from cache.'); |
403 | 403 | } else { |
404 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
404 | + $this->itemInstances[$item->getKey()] = $item; |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
@@ -414,10 +414,10 @@ discard block |
||
414 | 414 | protected function deregisterItem($item) |
415 | 415 | { |
416 | 416 | if ($item instanceof CacheItemInterface) { |
417 | - unset($this->itemInstances[ $item->getKey() ]); |
|
417 | + unset($this->itemInstances[$item->getKey()]); |
|
418 | 418 | |
419 | 419 | } else if (is_string($item)) { |
420 | - unset($this->itemInstances[ $item ]); |
|
420 | + unset($this->itemInstances[$item]); |
|
421 | 421 | } else { |
422 | 422 | throw new phpFastCacheInvalidArgumentException('Invalid type for $item variable'); |
423 | 423 | } |
@@ -436,8 +436,8 @@ discard block |
||
436 | 436 | */ |
437 | 437 | public function isAttached(CacheItemInterface $item) |
438 | 438 | { |
439 | - if (isset($this->itemInstances[ $item->getKey() ])) { |
|
440 | - return spl_object_hash($item) === spl_object_hash($this->itemInstances[ $item->getKey() ]); |
|
439 | + if (isset($this->itemInstances[$item->getKey()])) { |
|
440 | + return spl_object_hash($item) === spl_object_hash($this->itemInstances[$item->getKey()]); |
|
441 | 441 | } |
442 | 442 | return null; |
443 | 443 | } |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | */ |
458 | 458 | public function saveMultiple(...$items) |
459 | 459 | { |
460 | - if (isset($items[ 0 ]) && is_array($items[ 0 ])) { |
|
461 | - foreach ($items[ 0 ] as $item) { |
|
460 | + if (isset($items[0]) && is_array($items[0])) { |
|
461 | + foreach ($items[0] as $item) { |
|
462 | 462 | $this->save($item); |
463 | 463 | } |
464 | 464 | return true; |
@@ -62,7 +62,7 @@ |
||
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @param \Psr\Cache\CacheItemInterface $item |
65 | - * @return mixed |
|
65 | + * @return boolean |
|
66 | 66 | * @throws phpFastCacheInvalidArgumentException |
67 | 67 | */ |
68 | 68 | protected function driverWrite(CacheItemInterface $item) |
@@ -75,16 +75,16 @@ discard block |
||
75 | 75 | try { |
76 | 76 | $cacheData = $this->encode($this->driverPreWrap($item)); |
77 | 77 | $options = new Cassandra\ExecutionOptions([ |
78 | - 'arguments' => [ |
|
78 | + 'arguments' => [ |
|
79 | 79 | 'cache_uuid' => new Cassandra\Uuid(), |
80 | 80 | 'cache_id' => $item->getKey(), |
81 | 81 | 'cache_data' => $cacheData, |
82 | 82 | 'cache_creation_date' => new Cassandra\Timestamp((new \DateTime())->getTimestamp()), |
83 | 83 | 'cache_expiration_date' => new Cassandra\Timestamp($item->getExpirationDate()->getTimestamp()), |
84 | 84 | 'cache_length' => strlen($cacheData), |
85 | - ], |
|
86 | - 'consistency' => Cassandra::CONSISTENCY_ALL, |
|
87 | - 'serial_consistency' => Cassandra::CONSISTENCY_SERIAL, |
|
85 | + ], |
|
86 | + 'consistency' => Cassandra::CONSISTENCY_ALL, |
|
87 | + 'serial_consistency' => Cassandra::CONSISTENCY_SERIAL, |
|
88 | 88 | ]); |
89 | 89 | |
90 | 90 | $query = sprintf('INSERT INTO %s.%s |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | { |
123 | 123 | try { |
124 | 124 | $options = new Cassandra\ExecutionOptions([ |
125 | - 'arguments' => ['cache_id' => $item->getKey()], |
|
126 | - 'page_size' => 1, |
|
125 | + 'arguments' => ['cache_id' => $item->getKey()], |
|
126 | + 'page_size' => 1, |
|
127 | 127 | ]); |
128 | 128 | $query = sprintf( |
129 | - 'SELECT cache_data FROM %s.%s WHERE cache_id = :cache_id;', |
|
130 | - self::CASSANDRA_KEY_SPACE, |
|
131 | - self::CASSANDRA_TABLE |
|
129 | + 'SELECT cache_data FROM %s.%s WHERE cache_id = :cache_id;', |
|
130 | + self::CASSANDRA_KEY_SPACE, |
|
131 | + self::CASSANDRA_TABLE |
|
132 | 132 | ); |
133 | 133 | $results = $this->instance->execute(new Cassandra\SimpleStatement($query), $options); |
134 | 134 | |
@@ -155,14 +155,14 @@ discard block |
||
155 | 155 | if ($item instanceof Item) { |
156 | 156 | try { |
157 | 157 | $options = new Cassandra\ExecutionOptions([ |
158 | - 'arguments' => [ |
|
158 | + 'arguments' => [ |
|
159 | 159 | 'cache_id' => $item->getKey(), |
160 | - ], |
|
160 | + ], |
|
161 | 161 | ]); |
162 | 162 | $result = $this->instance->execute(new Cassandra\SimpleStatement(sprintf( |
163 | - 'DELETE FROM %s.%s WHERE cache_id = :cache_id;', |
|
164 | - self::CASSANDRA_KEY_SPACE, |
|
165 | - self::CASSANDRA_TABLE |
|
163 | + 'DELETE FROM %s.%s WHERE cache_id = :cache_id;', |
|
164 | + self::CASSANDRA_KEY_SPACE, |
|
165 | + self::CASSANDRA_TABLE |
|
166 | 166 | )), $options); |
167 | 167 | |
168 | 168 | /** |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | { |
187 | 187 | try { |
188 | 188 | $this->instance->execute(new Cassandra\SimpleStatement(sprintf( |
189 | - 'TRUNCATE %s.%s;', |
|
190 | - self::CASSANDRA_KEY_SPACE, self::CASSANDRA_TABLE |
|
189 | + 'TRUNCATE %s.%s;', |
|
190 | + self::CASSANDRA_KEY_SPACE, self::CASSANDRA_TABLE |
|
191 | 191 | ))); |
192 | 192 | |
193 | 193 | return true; |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
214 | 214 | |
215 | 215 | $clusterBuilder = Cassandra::cluster() |
216 | - ->withContactPoints($host) |
|
217 | - ->withPort($port); |
|
216 | + ->withContactPoints($host) |
|
217 | + ->withPort($port); |
|
218 | 218 | |
219 | 219 | if (!empty($this->config[ 'ssl' ][ 'enabled' ])) { |
220 | 220 | if (!empty($this->config[ 'ssl' ][ 'verify' ])) { |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | */ |
243 | 243 | |
244 | 244 | $this->instance->execute(new Cassandra\SimpleStatement(sprintf( |
245 | - "CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", |
|
246 | - self::CASSANDRA_KEY_SPACE |
|
245 | + "CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", |
|
246 | + self::CASSANDRA_KEY_SPACE |
|
247 | 247 | ))); |
248 | 248 | $this->instance->execute(new Cassandra\SimpleStatement(sprintf('USE %s;', self::CASSANDRA_KEY_SPACE))); |
249 | 249 | $this->instance->execute(new Cassandra\SimpleStatement(sprintf(' |
@@ -290,15 +290,15 @@ discard block |
||
290 | 290 | public function getStats() |
291 | 291 | { |
292 | 292 | $result = $this->instance->execute(new Cassandra\SimpleStatement(sprintf( |
293 | - 'SELECT SUM(cache_length) as cache_size FROM %s.%s', |
|
294 | - self::CASSANDRA_KEY_SPACE, |
|
295 | - self::CASSANDRA_TABLE |
|
293 | + 'SELECT SUM(cache_length) as cache_size FROM %s.%s', |
|
294 | + self::CASSANDRA_KEY_SPACE, |
|
295 | + self::CASSANDRA_TABLE |
|
296 | 296 | ))); |
297 | 297 | |
298 | 298 | return (new DriverStatistic()) |
299 | - ->setSize($result->first()[ 'cache_size' ]) |
|
300 | - ->setRawData([]) |
|
301 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
302 | - ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.'); |
|
299 | + ->setSize($result->first()[ 'cache_size' ]) |
|
300 | + ->setRawData([]) |
|
301 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
302 | + ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.'); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | \ No newline at end of file |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $results = $this->instance->execute(new Cassandra\SimpleStatement($query), $options); |
134 | 134 | |
135 | 135 | if ($results instanceof Cassandra\Rows && $results->count() === 1) { |
136 | - return $this->decode($results->first()[ 'cache_data' ]); |
|
136 | + return $this->decode($results->first()['cache_data']); |
|
137 | 137 | } else { |
138 | 138 | return null; |
139 | 139 | } |
@@ -206,18 +206,18 @@ discard block |
||
206 | 206 | if ($this->instance instanceof CassandraSession) { |
207 | 207 | throw new phpFastCacheLogicException('Already connected to Couchbase server'); |
208 | 208 | } else { |
209 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
210 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : 9042; |
|
211 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 2; |
|
212 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
213 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
209 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
210 | + $port = isset($this->config['port']) ? $this->config['port'] : 9042; |
|
211 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 2; |
|
212 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
213 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
214 | 214 | |
215 | 215 | $clusterBuilder = Cassandra::cluster() |
216 | 216 | ->withContactPoints($host) |
217 | 217 | ->withPort($port); |
218 | 218 | |
219 | - if (!empty($this->config[ 'ssl' ][ 'enabled' ])) { |
|
220 | - if (!empty($this->config[ 'ssl' ][ 'verify' ])) { |
|
219 | + if (!empty($this->config['ssl']['enabled'])) { |
|
220 | + if (!empty($this->config['ssl']['verify'])) { |
|
221 | 221 | $sslBuilder = Cassandra::ssl()->withVerifyFlags(Cassandra::VERIFY_PEER_CERT); |
222 | 222 | } else { |
223 | 223 | $sslBuilder = Cassandra::ssl()->withVerifyFlags(Cassandra::VERIFY_NONE); |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | ))); |
297 | 297 | |
298 | 298 | return (new DriverStatistic()) |
299 | - ->setSize($result->first()[ 'cache_size' ]) |
|
299 | + ->setSize($result->first()['cache_size']) |
|
300 | 300 | ->setRawData([]) |
301 | 301 | ->setData(implode(', ', array_keys($this->itemInstances))) |
302 | 302 | ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.'); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @param \Psr\Cache\CacheItemInterface $item |
63 | - * @return mixed |
|
63 | + * @return boolean |
|
64 | 64 | * @throws phpFastCacheInvalidArgumentException |
65 | 65 | */ |
66 | 66 | protected function driverWrite(CacheItemInterface $item) |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | /** |
147 | 147 | * @param string $optionName |
148 | 148 | * @param mixed $optionValue |
149 | - * @return bool |
|
149 | + * @return boolean|null |
|
150 | 150 | * @throws phpFastCacheInvalidArgumentException |
151 | 151 | */ |
152 | 152 | public static function isValidOption($optionName, $optionValue) |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
182 | - * @return array |
|
182 | + * @return string[] |
|
183 | 183 | */ |
184 | 184 | public static function getValidOptions() |
185 | 185 | { |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
190 | - * @return array |
|
190 | + * @return string[] |
|
191 | 191 | */ |
192 | 192 | public static function getRequiredOptions() |
193 | 193 | { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * Force write |
77 | 77 | */ |
78 | 78 | try { |
79 | - return $this->writefile($file_path, $data, $this->config[ 'secureFileManipulation' ]); |
|
79 | + return $this->writefile($file_path, $data, $this->config['secureFileManipulation']); |
|
80 | 80 | } catch (\Exception $e) { |
81 | 81 | return false; |
82 | 82 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | protected function driverClear() |
138 | 138 | { |
139 | - return (bool)Directory::rrmdir($this->getPath(true)); |
|
139 | + return (bool) Directory::rrmdir($this->getPath(true)); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -43,7 +43,7 @@ |
||
43 | 43 | $this->driver->setItem($this); |
44 | 44 | } else { |
45 | 45 | throw new phpFastCacheInvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', |
46 | - gettype($key))); |
|
46 | + gettype($key))); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 |
@@ -62,7 +62,7 @@ |
||
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @param \Psr\Cache\CacheItemInterface $item |
65 | - * @return mixed |
|
65 | + * @return boolean |
|
66 | 66 | * @throws phpFastCacheInvalidArgumentException |
67 | 67 | */ |
68 | 68 | protected function driverWrite(CacheItemInterface $item) |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | protected function driverRead(CacheItemInterface $item) |
77 | 77 | { |
78 | 78 | return [ |
79 | - self::DRIVER_DATA_WRAPPER_INDEX => false, |
|
80 | - self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
81 | - self::DRIVER_EDATE_WRAPPER_INDEX => new \DateTime(), |
|
79 | + self::DRIVER_DATA_WRAPPER_INDEX => false, |
|
80 | + self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
81 | + self::DRIVER_EDATE_WRAPPER_INDEX => new \DateTime(), |
|
82 | 82 | ]; |
83 | 83 | } |
84 | 84 | |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | { |
129 | 129 | $stat = new DriverStatistic(); |
130 | 130 | $stat->setInfo('[Devfalse] A void info string') |
131 | - ->setSize(0) |
|
132 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
133 | - ->setRawData(false); |
|
131 | + ->setSize(0) |
|
132 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
133 | + ->setRawData(false); |
|
134 | 134 | |
135 | 135 | return $stat; |
136 | 136 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @param \Psr\Cache\CacheItemInterface $item |
65 | - * @return mixed |
|
65 | + * @return boolean |
|
66 | 66 | * @throws phpFastCacheInvalidArgumentException |
67 | 67 | */ |
68 | 68 | protected function driverWrite(CacheItemInterface $item) |
@@ -127,9 +127,9 @@ |
||
127 | 127 | { |
128 | 128 | $stat = new DriverStatistic(); |
129 | 129 | $stat->setInfo('[Devnull] A void info string') |
130 | - ->setSize(0) |
|
131 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
132 | - ->setRawData(null); |
|
130 | + ->setSize(0) |
|
131 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
132 | + ->setRawData(null); |
|
133 | 133 | |
134 | 134 | return $stat; |
135 | 135 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @param \Psr\Cache\CacheItemInterface $item |
65 | - * @return mixed |
|
65 | + * @return boolean |
|
66 | 66 | * @throws phpFastCacheInvalidArgumentException |
67 | 67 | */ |
68 | 68 | protected function driverWrite(CacheItemInterface $item) |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | protected function driverRead(CacheItemInterface $item) |
81 | 81 | { |
82 | 82 | return [ |
83 | - self::DRIVER_DATA_WRAPPER_INDEX => true, |
|
84 | - self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
85 | - self::DRIVER_EDATE_WRAPPER_INDEX => new \DateTime(), |
|
83 | + self::DRIVER_DATA_WRAPPER_INDEX => true, |
|
84 | + self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
85 | + self::DRIVER_EDATE_WRAPPER_INDEX => new \DateTime(), |
|
86 | 86 | ]; |
87 | 87 | } |
88 | 88 | |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | { |
133 | 133 | $stat = new DriverStatistic(); |
134 | 134 | $stat->setInfo('[Devtrue] A void info string') |
135 | - ->setSize(0) |
|
136 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
137 | - ->setRawData(true); |
|
135 | + ->setSize(0) |
|
136 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
137 | + ->setRawData(true); |
|
138 | 138 | |
139 | 139 | return $stat; |
140 | 140 | } |
@@ -76,7 +76,7 @@ |
||
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @param \Psr\Cache\CacheItemInterface $item |
79 | - * @return mixed |
|
79 | + * @return boolean |
|
80 | 80 | * @throws phpFastCacheInvalidArgumentException |
81 | 81 | * @throws phpFastCacheDriverException |
82 | 82 | */ |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | if ($item instanceof Item) { |
89 | 89 | try { |
90 | 90 | $result = (array)$this->getCollection()->updateOne( |
91 | - ['_id' => $item->getEncodedKey()], |
|
92 | - [ |
|
91 | + ['_id' => $item->getEncodedKey()], |
|
92 | + [ |
|
93 | 93 | '$set' => [ |
94 | - self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC), |
|
95 | - self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC), |
|
96 | - self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time() * 1000)), |
|
94 | + self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC), |
|
95 | + self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC), |
|
96 | + self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time() * 1000)), |
|
97 | 97 | ], |
98 | - ], |
|
99 | - ['upsert' => true, 'multiple' => false] |
|
98 | + ], |
|
99 | + ['upsert' => true, 'multiple' => false] |
|
100 | 100 | ); |
101 | 101 | } catch (MongoDBException $e) { |
102 | 102 | throw new phpFastCacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e); |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | |
119 | 119 | if ($document) { |
120 | 120 | return [ |
121 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
122 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
123 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
121 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
122 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
123 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
124 | 124 | ]; |
125 | 125 | } else { |
126 | 126 | return null; |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | * @todo make an url builder |
192 | 192 | */ |
193 | 193 | $this->instance = $this->instance ?: (new MongodbManager('mongodb://' . |
194 | - ($username ?: '') . |
|
195 | - ($password ? ":{$password}" : '') . |
|
196 | - ($username ? '@' : '') . "{$host}" . |
|
197 | - ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000])); |
|
194 | + ($username ?: '') . |
|
195 | + ($password ? ":{$password}" : '') . |
|
196 | + ($username ? '@' : '') . "{$host}" . |
|
197 | + ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000])); |
|
198 | 198 | $this->collection = $this->collection ?: new Collection($this->instance, $databaseName, $collectionName); |
199 | 199 | |
200 | 200 | return true; |
@@ -222,15 +222,15 @@ discard block |
||
222 | 222 | public function getStats() |
223 | 223 | { |
224 | 224 | $serverStats = $this->instance->executeCommand('phpFastCache', new Command([ |
225 | - 'serverStatus' => 1, |
|
226 | - 'recordStats' => 0, |
|
227 | - 'repl' => 0, |
|
228 | - 'metrics' => 0, |
|
225 | + 'serverStatus' => 1, |
|
226 | + 'recordStats' => 0, |
|
227 | + 'repl' => 0, |
|
228 | + 'metrics' => 0, |
|
229 | 229 | ]))->toArray()[ 0 ]; |
230 | 230 | |
231 | 231 | $collectionStats = $this->instance->executeCommand('phpFastCache', new Command([ |
232 | - 'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'), |
|
233 | - 'verbose' => true, |
|
232 | + 'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'), |
|
233 | + 'verbose' => true, |
|
234 | 234 | ]))->toArray()[ 0 ]; |
235 | 235 | |
236 | 236 | $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) { |
@@ -259,14 +259,14 @@ discard block |
||
259 | 259 | $collectionStats = $array_filter_recursive($collectionStats, $callback); |
260 | 260 | |
261 | 261 | $stats = (new DriverStatistic()) |
262 | - ->setInfo('MongoDB version ' . $serverStats->version . ', Uptime (in days): ' . round($serverStats->uptime / 86400, |
|
263 | - 1) . "\n For more information see RawData.") |
|
264 | - ->setSize($collectionStats->size) |
|
265 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
266 | - ->setRawData([ |
|
262 | + ->setInfo('MongoDB version ' . $serverStats->version . ', Uptime (in days): ' . round($serverStats->uptime / 86400, |
|
263 | + 1) . "\n For more information see RawData.") |
|
264 | + ->setSize($collectionStats->size) |
|
265 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
266 | + ->setRawData([ |
|
267 | 267 | 'serverStatus' => $serverStats, |
268 | 268 | 'collStats' => $collectionStats, |
269 | - ]); |
|
269 | + ]); |
|
270 | 270 | |
271 | 271 | return $stats; |
272 | 272 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | if ($item instanceof Item) { |
89 | 89 | try { |
90 | - $result = (array)$this->getCollection()->updateOne( |
|
90 | + $result = (array) $this->getCollection()->updateOne( |
|
91 | 91 | ['_id' => $item->getEncodedKey()], |
92 | 92 | [ |
93 | 93 | '$set' => [ |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | throw new phpFastCacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e); |
103 | 103 | } |
104 | 104 | |
105 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
105 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
106 | 106 | } else { |
107 | 107 | throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected'); |
108 | 108 | } |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | |
119 | 119 | if ($document) { |
120 | 120 | return [ |
121 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
122 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
123 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
121 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->getData()), |
|
122 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->getData()), |
|
123 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_EDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()), |
|
124 | 124 | ]; |
125 | 125 | } else { |
126 | 126 | return null; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | $this->save($this->getItem('__PFC_CACHE_CLEARED__')->set(true)); |
167 | 167 | |
168 | - return !empty($result[ 'ok' ]); |
|
168 | + return !empty($result['ok']); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | if ($this->instance instanceof \MongoDB\Driver\Manager) { |
179 | 179 | throw new LogicException('Already connected to Mongodb server'); |
180 | 180 | } else { |
181 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
182 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : '27017'; |
|
183 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 3; |
|
184 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
185 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
186 | - $collectionName = isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'; |
|
187 | - $databaseName = isset($this->config[ 'databaseName' ]) ? $this->config[ 'databaseName' ] : 'phpFastCache'; |
|
181 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
182 | + $port = isset($this->config['port']) ? $this->config['port'] : '27017'; |
|
183 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 3; |
|
184 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
185 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
186 | + $collectionName = isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache'; |
|
187 | + $databaseName = isset($this->config['databaseName']) ? $this->config['databaseName'] : 'phpFastCache'; |
|
188 | 188 | |
189 | 189 | |
190 | 190 | /** |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | 'recordStats' => 0, |
227 | 227 | 'repl' => 0, |
228 | 228 | 'metrics' => 0, |
229 | - ]))->toArray()[ 0 ]; |
|
229 | + ]))->toArray()[0]; |
|
230 | 230 | |
231 | 231 | $collectionStats = $this->instance->executeCommand('phpFastCache', new Command([ |
232 | - 'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'), |
|
232 | + 'collStats' => (isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache'), |
|
233 | 233 | 'verbose' => true, |
234 | - ]))->toArray()[ 0 ]; |
|
234 | + ]))->toArray()[0]; |
|
235 | 235 | |
236 | - $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) { |
|
236 | + $array_filter_recursive = function($array, callable $callback = null) use (&$array_filter_recursive) { |
|
237 | 237 | $array = $callback($array); |
238 | 238 | |
239 | 239 | if (is_object($array) || is_array($array)) { |
@@ -245,12 +245,12 @@ discard block |
||
245 | 245 | return $array; |
246 | 246 | }; |
247 | 247 | |
248 | - $callback = function ($item) { |
|
248 | + $callback = function($item) { |
|
249 | 249 | /** |
250 | 250 | * Remove unserializable properties |
251 | 251 | */ |
252 | 252 | if ($item instanceof \MongoDB\BSON\UTCDateTime) { |
253 | - return (string)$item; |
|
253 | + return (string) $item; |
|
254 | 254 | } |
255 | 255 | return $item; |
256 | 256 | }; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | - * @return int|bool Return size in octet or false if no information available |
|
55 | + * @return string Return size in octet or false if no information available |
|
56 | 56 | */ |
57 | 57 | public function getSize() |
58 | 58 | { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | - * @return mixed |
|
63 | + * @return string |
|
64 | 64 | */ |
65 | 65 | public function getData() |
66 | 66 | { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | - * @param $info |
|
71 | + * @param string $info |
|
72 | 72 | * @return $this |
73 | 73 | */ |
74 | 74 | public function setInfo($info) |
@@ -123,10 +123,10 @@ |
||
123 | 123 | public function getPublicDesc() |
124 | 124 | { |
125 | 125 | return [ |
126 | - 'Info' => 'Cache Information', |
|
127 | - 'Size' => 'Cache Size', |
|
128 | - 'Data' => 'Cache items keys', |
|
129 | - 'RawData' => 'Cache raw data', |
|
126 | + 'Info' => 'Cache Information', |
|
127 | + 'Size' => 'Cache Size', |
|
128 | + 'Data' => 'Cache items keys', |
|
129 | + 'RawData' => 'Cache raw data', |
|
130 | 130 | ]; |
131 | 131 | } |
132 | 132 | } |
133 | 133 | \ No newline at end of file |