@@ -76,8 +76,8 @@ |
||
76 | 76 | { |
77 | 77 | try { |
78 | 78 | $cacheItem = $this->internalCacheInstance |
79 | - ->getItem($key) |
|
80 | - ->set($value); |
|
79 | + ->getItem($key) |
|
80 | + ->set($value); |
|
81 | 81 | if (is_int($ttl) && $ttl <= 0) { |
82 | 82 | $cacheItem->expiresAt((new \DateTime('@0'))); |
83 | 83 | } elseif (is_int($ttl) || $ttl instanceof \DateInterval) { |
@@ -128,7 +128,7 @@ |
||
128 | 128 | $keys = \iterator_to_array($keys); |
129 | 129 | } |
130 | 130 | try { |
131 | - return array_map(function (ExtendedCacheItemInterface $item) { |
|
131 | + return array_map(function(ExtendedCacheItemInterface $item) { |
|
132 | 132 | return $item->get(); |
133 | 133 | }, $this->internalCacheInstance->getItems($keys)); |
134 | 134 | } catch (phpFastCacheInvalidArgumentException $e) { |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
142 | 142 | $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
143 | 143 | $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
144 | - [ |
|
144 | + [ |
|
145 | 145 | 'bucket' => 'default', |
146 | 146 | 'password' => '', |
147 | - ], |
|
147 | + ], |
|
148 | 148 | ]; |
149 | 149 | |
150 | 150 | $this->instance = new CouchbaseClient("couchbase://{$host}:{$port}", $username, $password); |
@@ -194,10 +194,10 @@ discard block |
||
194 | 194 | $info = $this->getBucket()->manager()->info(); |
195 | 195 | |
196 | 196 | return (new DriverStatistic()) |
197 | - ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
198 | - ->setRawData($info) |
|
199 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
200 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, |
|
201 | - 1) . "\n For more information see RawData."); |
|
197 | + ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
198 | + ->setRawData($info) |
|
199 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
200 | + ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, |
|
201 | + 1) . "\n For more information see RawData."); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | \ No newline at end of file |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | if ($item instanceof Item) { |
81 | 81 | try { |
82 | - return (bool)$this->getBucket()->upsert($item->getEncodedKey(), $this->encode($this->driverPreWrap($item)), ['expiry' => $item->getTtl()]); |
|
82 | + return (bool) $this->getBucket()->upsert($item->getEncodedKey(), $this->encode($this->driverPreWrap($item)), ['expiry' => $item->getTtl()]); |
|
83 | 83 | } catch (\CouchbaseException $e) { |
84 | 84 | return false; |
85 | 85 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | if ($item instanceof Item) { |
118 | 118 | try { |
119 | - return (bool)$this->getBucket()->remove($item->getEncodedKey()); |
|
119 | + return (bool) $this->getBucket()->remove($item->getEncodedKey()); |
|
120 | 120 | } catch (\Couchbase\Exception $e) { |
121 | 121 | return $e->getCode() === COUCHBASE_KEY_ENOENT; |
122 | 122 | } |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | } else { |
145 | 145 | |
146 | 146 | |
147 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
148 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : 8091; |
|
149 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
150 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
151 | - $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
|
147 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
148 | + $port = isset($this->config['port']) ? $this->config['port'] : 8091; |
|
149 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
150 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
151 | + $buckets = isset($this->config['buckets']) ? $this->config['buckets'] : [ |
|
152 | 152 | [ |
153 | 153 | 'bucket' => 'default', |
154 | 154 | 'password' => '', |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | $this->instance = new CouchbaseClient("couchbase://{$host}:{$port}", $username, $password); |
159 | 159 | |
160 | 160 | foreach ($buckets as $bucket) { |
161 | - $this->bucketCurrent = $this->bucketCurrent ?: $bucket[ 'bucket' ]; |
|
162 | - $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ], $bucket[ 'password' ])); |
|
161 | + $this->bucketCurrent = $this->bucketCurrent ?: $bucket['bucket']; |
|
162 | + $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'], $bucket['password'])); |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | protected function getBucket() |
173 | 173 | { |
174 | - return $this->bucketInstances[ $this->bucketCurrent ]; |
|
174 | + return $this->bucketInstances[$this->bucketCurrent]; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | protected function setBucket($bucketName, \CouchbaseBucket $CouchbaseBucket) |
183 | 183 | { |
184 | 184 | if (!array_key_exists($bucketName, $this->bucketInstances)) { |
185 | - $this->bucketInstances[ $bucketName ] = $CouchbaseBucket; |
|
185 | + $this->bucketInstances[$bucketName] = $CouchbaseBucket; |
|
186 | 186 | } else { |
187 | 187 | throw new phpFastCacheLogicException('A bucket instance with this name already exists.'); |
188 | 188 | } |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | $info = $this->getBucket()->manager()->info(); |
203 | 203 | |
204 | 204 | return (new DriverStatistic()) |
205 | - ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
205 | + ->setSize($info['basicStats']['diskUsed']) |
|
206 | 206 | ->setRawData($info) |
207 | 207 | ->setData(implode(', ', array_keys($this->itemInstances))) |
208 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, |
|
208 | + ->setInfo('CouchBase version ' . $info['nodes'][0]['version'] . ', Uptime (in days): ' . round($info['nodes'][0]['uptime'] / 86400, |
|
209 | 209 | 1) . "\n For more information see RawData."); |
210 | 210 | } |
211 | 211 | } |
212 | 212 | \ No newline at end of file |
@@ -27,7 +27,7 @@ |
||
27 | 27 | public function __construct($message = "", $code = 0, $previous = null) |
28 | 28 | { |
29 | 29 | $lastError = error_get_last(); |
30 | - if($lastError){ |
|
30 | + if ($lastError) { |
|
31 | 31 | $message .= "\n"; |
32 | 32 | $message .= "Additional information provided by error_get_last():\n"; |
33 | 33 | $message .= "{$lastError['message']} in {$lastError['file']} line {$lastError['line']}"; |
@@ -152,7 +152,7 @@ |
||
152 | 152 | */ |
153 | 153 | if(!empty($server[ 'path' ]) && !$this->instance->addServer($server[ 'path' ], 0)){ |
154 | 154 | $this->fallback = true; |
155 | - }else if (!empty($server[ 'host' ]) && !$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
155 | + } else if (!empty($server[ 'host' ]) && !$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
156 | 156 | $this->fallback = true; |
157 | 157 | } |
158 | 158 |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
136 | 136 | if (count($servers) < 1) { |
137 | 137 | $servers = [ |
138 | - [ |
|
138 | + [ |
|
139 | 139 | 'host' => !empty($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1', |
140 | 140 | 'path' => !empty($this->config[ 'path' ]) ? $this->config[ 'path' ] : false, |
141 | 141 | 'port' => !empty($this->config[ 'port' ]) ? $this->config[ 'port' ] : 11211, |
142 | 142 | 'sasl_user' => !empty($this->config[ 'sasl_user' ]) ? $this->config[ 'sasl_user' ] : false, |
143 | 143 | 'sasl_password' =>!empty($this->config[ 'sasl_password' ]) ? $this->config[ 'sasl_password' ]: false, |
144 | - ], |
|
144 | + ], |
|
145 | 145 | ]; |
146 | 146 | } |
147 | 147 | |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
196 | 196 | |
197 | 197 | return (new DriverStatistic()) |
198 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
199 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
200 | - ->setRawData($stats) |
|
201 | - ->setSize($stats[ 'bytes' ]); |
|
198 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
199 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
200 | + ->setRawData($stats) |
|
201 | + ->setSize($stats[ 'bytes' ]); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | \ No newline at end of file |
@@ -132,15 +132,15 @@ discard block |
||
132 | 132 | { |
133 | 133 | $this->instance = new MemcachedSoftware(); |
134 | 134 | $this->instance->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); |
135 | - $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
|
135 | + $servers = (!empty($this->config['servers']) && is_array($this->config['servers']) ? $this->config['servers'] : []); |
|
136 | 136 | if (count($servers) < 1) { |
137 | 137 | $servers = [ |
138 | 138 | [ |
139 | - 'host' => !empty($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1', |
|
140 | - 'path' => !empty($this->config[ 'path' ]) ? $this->config[ 'path' ] : false, |
|
141 | - 'port' => !empty($this->config[ 'port' ]) ? $this->config[ 'port' ] : 11211, |
|
142 | - 'sasl_user' => !empty($this->config[ 'sasl_user' ]) ? $this->config[ 'sasl_user' ] : false, |
|
143 | - 'sasl_password' =>!empty($this->config[ 'sasl_password' ]) ? $this->config[ 'sasl_password' ]: false, |
|
139 | + 'host' => !empty($this->config['host']) ? $this->config['host'] : '127.0.0.1', |
|
140 | + 'path' => !empty($this->config['path']) ? $this->config['path'] : false, |
|
141 | + 'port' => !empty($this->config['port']) ? $this->config['port'] : 11211, |
|
142 | + 'sasl_user' => !empty($this->config['sasl_user']) ? $this->config['sasl_user'] : false, |
|
143 | + 'sasl_password' =>!empty($this->config['sasl_password']) ? $this->config['sasl_password'] : false, |
|
144 | 144 | ], |
145 | 145 | ]; |
146 | 146 | } |
@@ -150,14 +150,14 @@ discard block |
||
150 | 150 | /** |
151 | 151 | * If path is provided we consider it as an UNIX Socket |
152 | 152 | */ |
153 | - if(!empty($server[ 'path' ]) && !$this->instance->addServer($server[ 'path' ], 0)){ |
|
153 | + if (!empty($server['path']) && !$this->instance->addServer($server['path'], 0)) { |
|
154 | 154 | $this->fallback = true; |
155 | - }else if (!empty($server[ 'host' ]) && !$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
155 | + } else if (!empty($server['host']) && !$this->instance->addServer($server['host'], $server['port'])) { |
|
156 | 156 | $this->fallback = true; |
157 | 157 | } |
158 | 158 | |
159 | - if (!empty($server[ 'sasl_user' ]) && !empty($server[ 'sasl_password' ])) { |
|
160 | - $this->instance->setSaslAuthData($server[ 'sasl_user' ], $server[ 'sasl_password' ]); |
|
159 | + if (!empty($server['sasl_user']) && !empty($server['sasl_password'])) { |
|
160 | + $this->instance->setSaslAuthData($server['sasl_user'], $server['sasl_password']); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | } catch (\Exception $e) { |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * any error if not connected ... |
171 | 171 | */ |
172 | 172 | $version = $this->instance->getVersion(); |
173 | - if(!$version || $this->instance->getResultCode() !== MemcachedSoftware::RES_SUCCESS){ |
|
173 | + if (!$version || $this->instance->getResultCode() !== MemcachedSoftware::RES_SUCCESS) { |
|
174 | 174 | throw new phpFastCacheDriverException('Memcached seems to not be connected'); |
175 | 175 | } |
176 | 176 | return true; |
@@ -188,16 +188,16 @@ discard block |
||
188 | 188 | public function getStats() |
189 | 189 | { |
190 | 190 | $stats = current($this->instance->getStats()); |
191 | - $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
192 | - $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : $this->instance->getVersion()); |
|
193 | - $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
191 | + $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
|
192 | + $stats['version'] = (isset($stats['version']) ? $stats['version'] : $this->instance->getVersion()); |
|
193 | + $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
|
194 | 194 | |
195 | - $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
195 | + $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
|
196 | 196 | |
197 | 197 | return (new DriverStatistic()) |
198 | 198 | ->setData(implode(', ', array_keys($this->itemInstances))) |
199 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
199 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
200 | 200 | ->setRawData($stats) |
201 | - ->setSize($stats[ 'bytes' ]); |
|
201 | + ->setSize($stats['bytes']); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | \ No newline at end of file |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | $path = isset($config[ 'path' ]) ? (string) $config[ 'path' ] : false; |
139 | 139 | |
140 | 140 | $defaultConfig = [ |
141 | - 'host' => '127.0.0.1', |
|
142 | - 'port' => 6379, |
|
143 | - 'password' => null, |
|
144 | - 'database' => null, |
|
141 | + 'host' => '127.0.0.1', |
|
142 | + 'port' => 6379, |
|
143 | + 'password' => null, |
|
144 | + 'database' => null, |
|
145 | 145 | ]; |
146 | 146 | $config = array_merge($defaultConfig, $config); |
147 | 147 | |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | */ |
151 | 151 | if($path){ |
152 | 152 | $this->instance = new PredisClient([ |
153 | - 'scheme' => 'unix', |
|
154 | - 'path' => $path |
|
153 | + 'scheme' => 'unix', |
|
154 | + 'path' => $path |
|
155 | 155 | ]); |
156 | 156 | }else{ |
157 | 157 | $this->instance = new PredisClient($config); |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date'); |
198 | 198 | |
199 | 199 | return (new DriverStatistic()) |
200 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
201 | - ->setRawData($info) |
|
202 | - ->setSize($size) |
|
203 | - ->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.", |
|
200 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
201 | + ->setRawData($info) |
|
202 | + ->setSize($size) |
|
203 | + ->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.", |
|
204 | 204 | $version, $date->format(DATE_RFC2822))); |
205 | 205 | } |
206 | 206 | } |
207 | 207 | \ No newline at end of file |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * @see https://redis.io/commands/setex |
79 | 79 | * @see https://redis.io/commands/expire |
80 | 80 | */ |
81 | - if($ttl <= 0){ |
|
81 | + if ($ttl <= 0) { |
|
82 | 82 | return $this->instance->expire($item->getKey(), 0); |
83 | - }else{ |
|
83 | + } else { |
|
84 | 84 | return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item))); |
85 | 85 | } |
86 | 86 | } else { |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | protected function driverConnect() |
135 | 135 | { |
136 | 136 | /** Backward compatibility */ |
137 | - $config = isset($this->config[ 'predis' ]) ? $this->config[ 'predis' ] : $this->config; |
|
138 | - $path = isset($config[ 'path' ]) ? (string) $config[ 'path' ] : false; |
|
137 | + $config = isset($this->config['predis']) ? $this->config['predis'] : $this->config; |
|
138 | + $path = isset($config['path']) ? (string) $config['path'] : false; |
|
139 | 139 | |
140 | 140 | $defaultConfig = [ |
141 | 141 | 'host' => '127.0.0.1', |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | /** |
149 | 149 | * If path is provided we consider it as an UNIX Socket |
150 | 150 | */ |
151 | - if($path){ |
|
151 | + if ($path) { |
|
152 | 152 | $this->instance = new PredisClient([ |
153 | 153 | 'scheme' => 'unix', |
154 | 154 | 'path' => $path |
155 | 155 | ]); |
156 | - }else{ |
|
156 | + } else { |
|
157 | 157 | $this->instance = new PredisClient($config); |
158 | 158 | } |
159 | 159 | |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | public function getStats() |
193 | 193 | { |
194 | 194 | $info = $this->instance->info(); |
195 | - $size = (isset($info[ 'Memory' ][ 'used_memory' ]) ? $info[ 'Memory' ][ 'used_memory' ] : 0); |
|
196 | - $version = (isset($info[ 'Server' ][ 'redis_version' ]) ? $info[ 'Server' ][ 'redis_version' ] : 0); |
|
197 | - $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date'); |
|
195 | + $size = (isset($info['Memory']['used_memory']) ? $info['Memory']['used_memory'] : 0); |
|
196 | + $version = (isset($info['Server']['redis_version']) ? $info['Server']['redis_version'] : 0); |
|
197 | + $date = (isset($info['Server']['uptime_in_seconds']) ? (new \DateTime())->setTimestamp(time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
198 | 198 | |
199 | 199 | return (new DriverStatistic()) |
200 | 200 | ->setData(implode(', ', array_keys($this->itemInstances))) |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | if($ttl <= 0){ |
82 | 82 | return $this->instance->expire($item->getKey(), 0); |
83 | - }else{ |
|
83 | + } else{ |
|
84 | 84 | return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item))); |
85 | 85 | } |
86 | 86 | } else { |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'scheme' => 'unix', |
154 | 154 | 'path' => $path |
155 | 155 | ]); |
156 | - }else{ |
|
156 | + } else{ |
|
157 | 157 | $this->instance = new PredisClient($config); |
158 | 158 | } |
159 | 159 |
@@ -152,7 +152,7 @@ |
||
152 | 152 | */ |
153 | 153 | if(!empty($server[ 'path' ]) && !$this->instance->addServer($server[ 'path' ], 0)){ |
154 | 154 | $this->fallback = true; |
155 | - }else if (!empty($server[ 'host' ]) && !$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
155 | + } else if (!empty($server[ 'host' ]) && !$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
156 | 156 | $this->fallback = true; |
157 | 157 | } |
158 | 158 |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
136 | 136 | if (count($servers) < 1) { |
137 | 137 | $servers = [ |
138 | - [ |
|
138 | + [ |
|
139 | 139 | 'host' => !empty($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1', |
140 | 140 | 'path' => !empty($this->config[ 'path' ]) ? $this->config[ 'path' ] : false, |
141 | 141 | 'port' => !empty($this->config[ 'port' ]) ? $this->config[ 'port' ] : 11211, |
142 | 142 | 'sasl_user' => !empty($this->config[ 'sasl_user' ]) ? $this->config[ 'sasl_user' ] : false, |
143 | 143 | 'sasl_password' =>!empty($this->config[ 'sasl_password' ]) ? $this->config[ 'sasl_password' ]: false, |
144 | - ], |
|
144 | + ], |
|
145 | 145 | ]; |
146 | 146 | } |
147 | 147 | |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
196 | 196 | |
197 | 197 | return (new DriverStatistic()) |
198 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
199 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
200 | - ->setRawData($stats) |
|
201 | - ->setSize($stats[ 'bytes' ]); |
|
198 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
199 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
200 | + ->setRawData($stats) |
|
201 | + ->setSize($stats[ 'bytes' ]); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | \ No newline at end of file |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | } else { |
54 | 54 | $this->driverConnect(); |
55 | 55 | |
56 | - if (array_key_exists('compress_data', $config) && $config[ 'compress_data' ] === true) { |
|
56 | + if (array_key_exists('compress_data', $config) && $config['compress_data'] === true) { |
|
57 | 57 | $this->memcacheFlags = MEMCACHE_COMPRESSED; |
58 | 58 | } |
59 | 59 | } |
@@ -138,15 +138,15 @@ discard block |
||
138 | 138 | protected function driverConnect() |
139 | 139 | { |
140 | 140 | $this->instance = new MemcacheSoftware(); |
141 | - $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
|
141 | + $servers = (!empty($this->config['servers']) && is_array($this->config['servers']) ? $this->config['servers'] : []); |
|
142 | 142 | if (count($servers) < 1) { |
143 | 143 | $servers = [ |
144 | 144 | [ |
145 | - 'host' => !empty($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1', |
|
146 | - 'path' => !empty($this->config[ 'path' ]) ? $this->config[ 'path' ] : false, |
|
147 | - 'port' => !empty($this->config[ 'port' ]) ? $this->config[ 'port' ] : 11211, |
|
148 | - 'sasl_user' => !empty($this->config[ 'sasl_user' ]) ? $this->config[ 'sasl_user' ] : false, |
|
149 | - 'sasl_password' =>!empty($this->config[ 'sasl_password' ]) ? $this->config[ 'sasl_password' ]: false, |
|
145 | + 'host' => !empty($this->config['host']) ? $this->config['host'] : '127.0.0.1', |
|
146 | + 'path' => !empty($this->config['path']) ? $this->config['path'] : false, |
|
147 | + 'port' => !empty($this->config['port']) ? $this->config['port'] : 11211, |
|
148 | + 'sasl_user' => !empty($this->config['sasl_user']) ? $this->config['sasl_user'] : false, |
|
149 | + 'sasl_password' =>!empty($this->config['sasl_password']) ? $this->config['sasl_password'] : false, |
|
150 | 150 | ], |
151 | 151 | ]; |
152 | 152 | } |
@@ -156,13 +156,13 @@ discard block |
||
156 | 156 | /** |
157 | 157 | * If path is provided we consider it as an UNIX Socket |
158 | 158 | */ |
159 | - if(!empty($server[ 'path' ]) && !$this->instance->addServer($server[ 'path' ], 0)){ |
|
159 | + if (!empty($server['path']) && !$this->instance->addServer($server['path'], 0)) { |
|
160 | 160 | $this->fallback = true; |
161 | - }else if (!empty($server[ 'host' ]) && !$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
161 | + } else if (!empty($server['host']) && !$this->instance->addServer($server['host'], $server['port'])) { |
|
162 | 162 | $this->fallback = true; |
163 | 163 | } |
164 | 164 | |
165 | - if (!empty($server[ 'sasl_user' ]) && !empty($server[ 'sasl_password' ])) { |
|
165 | + if (!empty($server['sasl_user']) && !empty($server['sasl_password'])) { |
|
166 | 166 | throw new phpFastCacheDriverException('Unlike Memcached, Memcache does not support SASL authentication'); |
167 | 167 | } |
168 | 168 | } catch (\Exception $e) { |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * Since Memcached does not throw |
174 | 174 | * any error if not connected ... |
175 | 175 | */ |
176 | - if(!$this->instance->getServerStatus(!empty($server[ 'path' ]) ? $server[ 'path' ] : $server[ 'host' ], !empty($server[ 'port' ]) ? $server[ 'port' ] : 0)){ |
|
176 | + if (!$this->instance->getServerStatus(!empty($server['path']) ? $server['path'] : $server['host'], !empty($server['port']) ? $server['port'] : 0)) { |
|
177 | 177 | throw new phpFastCacheDriverException('Memcache seems to not be connected'); |
178 | 178 | } |
179 | 179 | } |
@@ -192,17 +192,17 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function getStats() |
194 | 194 | { |
195 | - $stats = (array)$this->instance->getstats(); |
|
196 | - $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
197 | - $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion'); |
|
198 | - $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
195 | + $stats = (array) $this->instance->getstats(); |
|
196 | + $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
|
197 | + $stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion'); |
|
198 | + $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
|
199 | 199 | |
200 | - $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
200 | + $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
|
201 | 201 | |
202 | 202 | return (new DriverStatistic()) |
203 | 203 | ->setData(implode(', ', array_keys($this->itemInstances))) |
204 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
204 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
205 | 205 | ->setRawData($stats) |
206 | - ->setSize($stats[ 'bytes' ]); |
|
206 | + ->setSize($stats['bytes']); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | \ No newline at end of file |
@@ -96,22 +96,22 @@ discard block |
||
96 | 96 | if ($item instanceof Item) { |
97 | 97 | try { |
98 | 98 | $set = [ |
99 | - self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC), |
|
100 | - self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC), |
|
101 | - self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time() * 1000)), |
|
99 | + self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC), |
|
100 | + self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC), |
|
101 | + self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time() * 1000)), |
|
102 | 102 | ]; |
103 | 103 | |
104 | 104 | if(!empty($this->config[ 'itemDetailedDate' ])){ |
105 | 105 | $set += [ |
106 | - self::DRIVER_MDATE_WRAPPER_INDEX => ($item->getModificationDate() ? new UTCDateTime(($item->getModificationDate()->getTimestamp()) * 1000) : new UTCDateTime(time() * 1000)), |
|
107 | - self::DRIVER_CDATE_WRAPPER_INDEX => ($item->getCreationDate() ? new UTCDateTime(($item->getCreationDate()->getTimestamp()) * 1000) : new UTCDateTime(time() * 1000)), |
|
106 | + self::DRIVER_MDATE_WRAPPER_INDEX => ($item->getModificationDate() ? new UTCDateTime(($item->getModificationDate()->getTimestamp()) * 1000) : new UTCDateTime(time() * 1000)), |
|
107 | + self::DRIVER_CDATE_WRAPPER_INDEX => ($item->getCreationDate() ? new UTCDateTime(($item->getCreationDate()->getTimestamp()) * 1000) : new UTCDateTime(time() * 1000)), |
|
108 | 108 | ]; |
109 | 109 | } |
110 | 110 | |
111 | 111 | $result = (array)$this->getCollection()->updateOne( |
112 | - ['_id' => $item->getEncodedKey()], |
|
113 | - ['$set' => $set], |
|
114 | - ['upsert' => true, 'multiple' => false] |
|
112 | + ['_id' => $item->getEncodedKey()], |
|
113 | + ['$set' => $set], |
|
114 | + ['upsert' => true, 'multiple' => false] |
|
115 | 115 | ); |
116 | 116 | } catch (MongoDBException $e) { |
117 | 117 | throw new phpFastCacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e); |
@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | |
134 | 134 | if ($document) { |
135 | 135 | $return = [ |
136 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
137 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
138 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
136 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
137 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
138 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
139 | 139 | ]; |
140 | 140 | |
141 | 141 | if(!empty($this->config[ 'itemDetailedDate' ])){ |
142 | 142 | $return += [ |
143 | - self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_MDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
144 | - self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_CDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
143 | + self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_MDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
144 | + self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_CDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
145 | 145 | ]; |
146 | 146 | } |
147 | 147 | |
@@ -281,15 +281,15 @@ discard block |
||
281 | 281 | public function getStats() |
282 | 282 | { |
283 | 283 | $serverStats = $this->instance->getManager()->executeCommand('phpFastCache', new Command([ |
284 | - 'serverStatus' => 1, |
|
285 | - 'recordStats' => 0, |
|
286 | - 'repl' => 0, |
|
287 | - 'metrics' => 0, |
|
284 | + 'serverStatus' => 1, |
|
285 | + 'recordStats' => 0, |
|
286 | + 'repl' => 0, |
|
287 | + 'metrics' => 0, |
|
288 | 288 | ]))->toArray()[ 0 ]; |
289 | 289 | |
290 | 290 | $collectionStats = $this->instance->getManager()->executeCommand('phpFastCache', new Command([ |
291 | - 'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'), |
|
292 | - 'verbose' => true, |
|
291 | + 'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'), |
|
292 | + 'verbose' => true, |
|
293 | 293 | ]))->toArray()[ 0 ]; |
294 | 294 | |
295 | 295 | $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) { |
@@ -318,14 +318,14 @@ discard block |
||
318 | 318 | $collectionStats = $array_filter_recursive($collectionStats, $callback); |
319 | 319 | |
320 | 320 | $stats = (new DriverStatistic()) |
321 | - ->setInfo('MongoDB version ' . $serverStats->version . ', Uptime (in days): ' . round($serverStats->uptime / 86400, |
|
322 | - 1) . "\n For more information see RawData.") |
|
323 | - ->setSize($collectionStats->size) |
|
324 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
325 | - ->setRawData([ |
|
321 | + ->setInfo('MongoDB version ' . $serverStats->version . ', Uptime (in days): ' . round($serverStats->uptime / 86400, |
|
322 | + 1) . "\n For more information see RawData.") |
|
323 | + ->setSize($collectionStats->size) |
|
324 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
325 | + ->setRawData([ |
|
326 | 326 | 'serverStatus' => $serverStats, |
327 | 327 | 'collStats' => $collectionStats, |
328 | - ]); |
|
328 | + ]); |
|
329 | 329 | |
330 | 330 | return $stats; |
331 | 331 | } |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time() * 1000)), |
102 | 102 | ]; |
103 | 103 | |
104 | - if(!empty($this->config[ 'itemDetailedDate' ])){ |
|
104 | + if (!empty($this->config['itemDetailedDate'])) { |
|
105 | 105 | $set += [ |
106 | 106 | self::DRIVER_MDATE_WRAPPER_INDEX => ($item->getModificationDate() ? new UTCDateTime(($item->getModificationDate()->getTimestamp()) * 1000) : new UTCDateTime(time() * 1000)), |
107 | 107 | self::DRIVER_CDATE_WRAPPER_INDEX => ($item->getCreationDate() ? new UTCDateTime(($item->getCreationDate()->getTimestamp()) * 1000) : new UTCDateTime(time() * 1000)), |
108 | 108 | ]; |
109 | 109 | } |
110 | 110 | |
111 | - $result = (array)$this->getCollection()->updateOne( |
|
111 | + $result = (array) $this->getCollection()->updateOne( |
|
112 | 112 | ['_id' => $item->getEncodedKey()], |
113 | 113 | ['$set' => $set], |
114 | 114 | ['upsert' => true, 'multiple' => false] |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | throw new phpFastCacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e); |
118 | 118 | } |
119 | 119 | |
120 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
120 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
121 | 121 | } else { |
122 | 122 | throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected'); |
123 | 123 | } |
@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | |
134 | 134 | if ($document) { |
135 | 135 | $return = [ |
136 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
137 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
138 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
136 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->getData()), |
|
137 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->getData()), |
|
138 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_EDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()), |
|
139 | 139 | ]; |
140 | 140 | |
141 | - if(!empty($this->config[ 'itemDetailedDate' ])){ |
|
141 | + if (!empty($this->config['itemDetailedDate'])) { |
|
142 | 142 | $return += [ |
143 | - self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_MDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
144 | - self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_CDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
143 | + self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_MDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()), |
|
144 | + self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_CDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()), |
|
145 | 145 | ]; |
146 | 146 | } |
147 | 147 | |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | if ($this->instance instanceof \MongoDB\Driver\Manager) { |
192 | 192 | throw new LogicException('Already connected to Mongodb server'); |
193 | 193 | } else { |
194 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] * 1000 : 3000; |
|
195 | - $collectionName = isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'; |
|
196 | - $databaseName = isset($this->config[ 'databaseName' ]) ? $this->config[ 'databaseName' ] : 'phpFastCache'; |
|
194 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] * 1000 : 3000; |
|
195 | + $collectionName = isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache'; |
|
196 | + $databaseName = isset($this->config['databaseName']) ? $this->config['databaseName'] : 'phpFastCache'; |
|
197 | 197 | |
198 | 198 | $this->instance = $this->instance ?: (new Client($this->buildConnectionURI($databaseName), ['connectTimeoutMS' => $timeout])); |
199 | 199 | $this->database = $this->database ?: $this->instance->selectDatabase($databaseName); |
@@ -234,10 +234,10 @@ discard block |
||
234 | 234 | */ |
235 | 235 | protected function buildConnectionURI($databaseName = '') |
236 | 236 | { |
237 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
238 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : '27017'; |
|
239 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
240 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
237 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
238 | + $port = isset($this->config['port']) ? $this->config['port'] : '27017'; |
|
239 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
240 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
241 | 241 | |
242 | 242 | $parts = [ |
243 | 243 | 'mongodb://', |
@@ -276,14 +276,14 @@ discard block |
||
276 | 276 | 'recordStats' => 0, |
277 | 277 | 'repl' => 0, |
278 | 278 | 'metrics' => 0, |
279 | - ]))->toArray()[ 0 ]; |
|
279 | + ]))->toArray()[0]; |
|
280 | 280 | |
281 | 281 | $collectionStats = $this->instance->getManager()->executeCommand('phpFastCache', new Command([ |
282 | - 'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'), |
|
282 | + 'collStats' => (isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache'), |
|
283 | 283 | 'verbose' => true, |
284 | - ]))->toArray()[ 0 ]; |
|
284 | + ]))->toArray()[0]; |
|
285 | 285 | |
286 | - $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) { |
|
286 | + $array_filter_recursive = function($array, callable $callback = null) use (&$array_filter_recursive) { |
|
287 | 287 | $array = $callback($array); |
288 | 288 | |
289 | 289 | if (is_object($array) || is_array($array)) { |
@@ -295,12 +295,12 @@ discard block |
||
295 | 295 | return $array; |
296 | 296 | }; |
297 | 297 | |
298 | - $callback = function ($item) { |
|
298 | + $callback = function($item) { |
|
299 | 299 | /** |
300 | 300 | * Remove unserializable properties |
301 | 301 | */ |
302 | 302 | if ($item instanceof \MongoDB\BSON\UTCDateTime) { |
303 | - return (string)$item; |
|
303 | + return (string) $item; |
|
304 | 304 | } |
305 | 305 | return $item; |
306 | 306 | }; |
@@ -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->getKey()); |
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,7 +414,7 @@ discard block |
||
414 | 414 | protected function deregisterItem($item) |
415 | 415 | { |
416 | 416 | if (is_string($item)) { |
417 | - unset($this->itemInstances[ $item ]); |
|
417 | + unset($this->itemInstances[$item]); |
|
418 | 418 | } else { |
419 | 419 | throw new phpFastCacheInvalidArgumentException('Invalid type for $item variable'); |
420 | 420 | } |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | */ |
442 | 442 | public function isAttached(CacheItemInterface $item) |
443 | 443 | { |
444 | - if (isset($this->itemInstances[ $item->getKey() ])) { |
|
445 | - return spl_object_hash($item) === spl_object_hash($this->itemInstances[ $item->getKey() ]); |
|
444 | + if (isset($this->itemInstances[$item->getKey()])) { |
|
445 | + return spl_object_hash($item) === spl_object_hash($this->itemInstances[$item->getKey()]); |
|
446 | 446 | } |
447 | 447 | return null; |
448 | 448 | } |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | */ |
463 | 463 | public function saveMultiple(...$items) |
464 | 464 | { |
465 | - if (isset($items[ 0 ]) && is_array($items[ 0 ])) { |
|
466 | - foreach ($items[ 0 ] as $item) { |
|
465 | + if (isset($items[0]) && is_array($items[0])) { |
|
466 | + foreach ($items[0] as $item) { |
|
467 | 467 | $this->save($item); |
468 | 468 | } |
469 | 469 | return true; |