@@ -17,9 +17,9 @@ |
||
17 | 17 | /** |
18 | 18 | * Register Autoload |
19 | 19 | */ |
20 | -spl_autoload_register(function ($entity) { |
|
20 | +spl_autoload_register(function($entity) { |
|
21 | 21 | $module = explode('\\', $entity, 2); |
22 | - if (!in_array($module[ 0 ], ['phpFastCache', 'Psr'])) { |
|
22 | + if (!in_array($module[0], ['phpFastCache', 'Psr'])) { |
|
23 | 23 | /** |
24 | 24 | * Not a part of phpFastCache file |
25 | 25 | * then we return here. |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function driverConnect() |
128 | 128 | { |
129 | - $server = isset($this->config[ 'redis' ]) ? $this->config[ 'redis' ] : [ |
|
129 | + $server = isset($this->config['redis']) ? $this->config['redis'] : [ |
|
130 | 130 | 'host' => '127.0.0.1', |
131 | 131 | 'port' => '6379', |
132 | 132 | 'password' => '', |
@@ -134,32 +134,32 @@ discard block |
||
134 | 134 | ]; |
135 | 135 | |
136 | 136 | $config = [ |
137 | - 'host' => $server[ 'host' ], |
|
137 | + 'host' => $server['host'], |
|
138 | 138 | ]; |
139 | 139 | |
140 | - $port = isset($server[ 'port' ]) ? $server[ 'port' ] : ''; |
|
140 | + $port = isset($server['port']) ? $server['port'] : ''; |
|
141 | 141 | if ($port != '') { |
142 | - $config[ 'port' ] = $port; |
|
142 | + $config['port'] = $port; |
|
143 | 143 | } |
144 | 144 | |
145 | - $password = isset($server[ 'password' ]) ? $server[ 'password' ] : ''; |
|
145 | + $password = isset($server['password']) ? $server['password'] : ''; |
|
146 | 146 | if ($password != '') { |
147 | - $config[ 'password' ] = $password; |
|
147 | + $config['password'] = $password; |
|
148 | 148 | } |
149 | 149 | |
150 | - $database = isset($server[ 'database' ]) ? $server[ 'database' ] : ''; |
|
150 | + $database = isset($server['database']) ? $server['database'] : ''; |
|
151 | 151 | if ($database != '') { |
152 | - $config[ 'database' ] = $database; |
|
152 | + $config['database'] = $database; |
|
153 | 153 | } |
154 | 154 | |
155 | - $timeout = isset($server[ 'timeout' ]) ? $server[ 'timeout' ] : ''; |
|
155 | + $timeout = isset($server['timeout']) ? $server['timeout'] : ''; |
|
156 | 156 | if ($timeout != '') { |
157 | - $config[ 'timeout' ] = $timeout; |
|
157 | + $config['timeout'] = $timeout; |
|
158 | 158 | } |
159 | 159 | |
160 | - $read_write_timeout = isset($server[ 'read_write_timeout' ]) ? $server[ 'read_write_timeout' ] : ''; |
|
160 | + $read_write_timeout = isset($server['read_write_timeout']) ? $server['read_write_timeout'] : ''; |
|
161 | 161 | if ($read_write_timeout != '') { |
162 | - $config[ 'read_write_timeout' ] = $read_write_timeout; |
|
162 | + $config['read_write_timeout'] = $read_write_timeout; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | $this->instance = new PredisClient($config); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $this->instance = new MemcacheSoftware(); |
53 | 53 | $this->driverConnect(); |
54 | 54 | |
55 | - if (array_key_exists('compress_data', $config) && $config[ 'compress_data' ] === true) { |
|
55 | + if (array_key_exists('compress_data', $config) && $config['compress_data'] === true) { |
|
56 | 56 | $this->memcacheFlags = MEMCACHE_COMPRESSED; |
57 | 57 | } |
58 | 58 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function driverConnect() |
132 | 132 | { |
133 | - $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
|
133 | + $servers = (!empty($this->config['memcache']) && is_array($this->config['memcache']) ? $this->config['memcache'] : []); |
|
134 | 134 | if (count($servers) < 1) { |
135 | 135 | $servers = [ |
136 | 136 | ['127.0.0.1', 11211], |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | foreach ($servers as $server) { |
141 | 141 | try { |
142 | - if (!$this->instance->addserver($server[ 0 ], $server[ 1 ])) { |
|
142 | + if (!$this->instance->addserver($server[0], $server[1])) { |
|
143 | 143 | $this->fallback = true; |
144 | 144 | } |
145 | 145 | } catch (\Exception $e) { |
@@ -122,11 +122,11 @@ |
||
122 | 122 | } else { |
123 | 123 | $this->instance = $this->instance ?: new RedisClient(); |
124 | 124 | |
125 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
126 | - $port = isset($this->config[ 'port' ]) ? (int) $this->config[ 'port' ] : '6379'; |
|
127 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
128 | - $database = isset($this->config[ 'database' ]) ? $this->config[ 'database' ] : ''; |
|
129 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : ''; |
|
125 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
126 | + $port = isset($this->config['port']) ? (int) $this->config['port'] : '6379'; |
|
127 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
128 | + $database = isset($this->config['database']) ? $this->config['database'] : ''; |
|
129 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : ''; |
|
130 | 130 | |
131 | 131 | if (!$this->instance->connect($host, (int) $port, (int) $timeout)) { |
132 | 132 | return false; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $keyword = self::PREFIX . $item->getKey(); |
80 | 80 | $v = json_encode($this->driverPreWrap($item)); |
81 | 81 | |
82 | - if (isset($this->config[ 'limited_memory_each_object' ]) && strlen($v) > $this->config[ 'limited_memory_each_object' ]) { |
|
82 | + if (isset($this->config['limited_memory_each_object']) && strlen($v) > $this->config['limited_memory_each_object']) { |
|
83 | 83 | return false; |
84 | 84 | } |
85 | 85 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | // return null if no caching |
101 | 101 | // return value if in caching |
102 | 102 | $keyword = self::PREFIX . $key; |
103 | - $x = isset($_COOKIE[ $keyword ]) ? $this->decode(json_decode($_COOKIE[ $keyword ], true)) : false; |
|
103 | + $x = isset($_COOKIE[$keyword]) ? $this->decode(json_decode($_COOKIE[$keyword], true)) : false; |
|
104 | 104 | |
105 | 105 | if ($x == false) { |
106 | 106 | return null; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | { |
122 | 122 | $this->driverConnect(); |
123 | 123 | $keyword = self::PREFIX . $key; |
124 | - $x = isset($_COOKIE[ $keyword ]) ? $this->decode(json_decode($_COOKIE[ $keyword ])->t) : false; |
|
124 | + $x = isset($_COOKIE[$keyword]) ? $this->decode(json_decode($_COOKIE[$keyword])->t) : false; |
|
125 | 125 | |
126 | 126 | return $x ? $x - time() : $x; |
127 | 127 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | if ($item instanceof Item) { |
140 | 140 | $this->driverConnect(); |
141 | 141 | $keyword = self::PREFIX . $item->getKey(); |
142 | - $_COOKIE[ $keyword ] = null; |
|
142 | + $_COOKIE[$keyword] = null; |
|
143 | 143 | |
144 | 144 | return @setcookie($keyword, null, -10); |
145 | 145 | } else { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $this->driverConnect(); |
157 | 157 | foreach ($_COOKIE as $keyword => $value) { |
158 | 158 | if (strpos($keyword, self::PREFIX) !== false) { |
159 | - $_COOKIE[ $keyword ] = null; |
|
159 | + $_COOKIE[$keyword] = null; |
|
160 | 160 | $result = @setcookie($keyword, null, -10); |
161 | 161 | if ($return !== false) { |
162 | 162 | $return = $result; |
@@ -145,18 +145,18 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function driverConnect() |
147 | 147 | { |
148 | - try{ |
|
149 | - $server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : [ |
|
148 | + try { |
|
149 | + $server = isset($this->config['ssdb']) ? $this->config['ssdb'] : [ |
|
150 | 150 | 'host' => "127.0.0.1", |
151 | 151 | 'port' => 8888, |
152 | 152 | 'password' => '', |
153 | 153 | 'timeout' => 2000, |
154 | 154 | ]; |
155 | 155 | |
156 | - $host = $server[ 'host' ]; |
|
157 | - $port = isset($server[ 'port' ]) ? (int) $server[ 'port' ] : 8888; |
|
158 | - $password = isset($server[ 'password' ]) ? $server[ 'password' ] : ''; |
|
159 | - $timeout = !empty($server[ 'timeout' ]) ? (int) $server[ 'timeout' ] : 2000; |
|
156 | + $host = $server['host']; |
|
157 | + $port = isset($server['port']) ? (int) $server['port'] : 8888; |
|
158 | + $password = isset($server['password']) ? $server['password'] : ''; |
|
159 | + $timeout = !empty($server['timeout']) ? (int) $server['timeout'] : 2000; |
|
160 | 160 | $this->instance = new SimpleSSDB($host, $port, $timeout); |
161 | 161 | if (!empty($password)) { |
162 | 162 | $this->instance->auth($password); |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | } else { |
168 | 168 | return true; |
169 | 169 | } |
170 | - }catch(SSDBException $e){ |
|
171 | - throw new phpFastCacheDriverException('Ssdb failed to connect with error: '. $e->getMessage(), 0 , $e); |
|
170 | + } catch (SSDBException $e) { |
|
171 | + throw new phpFastCacheDriverException('Ssdb failed to connect with error: ' . $e->getMessage(), 0, $e); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | if (is_array($config_name)) { |
66 | 66 | $this->config = array_merge($this->config, $config_name); |
67 | 67 | } else { |
68 | - $this->config[ $config_name ] = $value; |
|
68 | + $this->config[$config_name] = $value; |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function driverUnwrapData(array $wrapper) |
184 | 184 | { |
185 | - return $wrapper[ self::DRIVER_DATA_WRAPPER_INDEX ]; |
|
185 | + return $wrapper[self::DRIVER_DATA_WRAPPER_INDEX]; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function driverUnwrapTags(array $wrapper) |
193 | 193 | { |
194 | - return $wrapper[ self::DRIVER_TAGS_WRAPPER_INDEX ]; |
|
194 | + return $wrapper[self::DRIVER_TAGS_WRAPPER_INDEX]; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function driverUnwrapTime(array $wrapper) |
203 | 203 | { |
204 | - return $wrapper[ self::DRIVER_TIME_WRAPPER_INDEX ]; |
|
204 | + return $wrapper[self::DRIVER_TIME_WRAPPER_INDEX]; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | foreach ($tagsItems as $tagsItem) { |
256 | 256 | $data = (array) $tagsItem->get(); |
257 | 257 | |
258 | - unset($data[ $item->getKey() ]); |
|
258 | + unset($data[$item->getKey()]); |
|
259 | 259 | $tagsItem->set($data); |
260 | 260 | |
261 | 261 | /** |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | */ |
307 | 307 | public static function isValidOption($optionName, $optionValue) |
308 | 308 | { |
309 | - if(!is_string($optionName)) |
|
309 | + if (!is_string($optionName)) |
|
310 | 310 | { |
311 | 311 | throw new \InvalidArgumentException('$optionName must be a string'); |
312 | 312 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | /* |
77 | 77 | * Skip if Existing Caching in Options |
78 | 78 | */ |
79 | - if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true && file_exists($file_path)) { |
|
79 | + if (isset($option['skipExisting']) && $option['skipExisting'] == true && file_exists($file_path)) { |
|
80 | 80 | $content = $this->readfile($file_path); |
81 | 81 | $old = $this->decode($content); |
82 | 82 | $toWrite = false; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | public static function isValidOption($optionName, $optionValue) |
223 | 223 | { |
224 | 224 | parent::isValidOption($optionName, $optionValue); |
225 | - switch($optionName) |
|
225 | + switch ($optionName) |
|
226 | 226 | { |
227 | 227 | case 'path': |
228 | 228 | return is_string($optionValue); |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | } else { |
138 | 138 | |
139 | 139 | |
140 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
140 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
141 | 141 | //$port = isset($server[ 'port' ]) ? $server[ 'port' ] : '11211'; |
142 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
143 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
144 | - $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
|
142 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
143 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
144 | + $buckets = isset($this->config['buckets']) ? $this->config['buckets'] : [ |
|
145 | 145 | [ |
146 | 146 | 'bucket' => 'default', |
147 | 147 | 'password' => '', |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | $this->instance = $this->instance ?: new CouchbaseClient("couchbase://{$host}", $username, $password); |
152 | 152 | |
153 | 153 | foreach ($buckets as $bucket) { |
154 | - $this->bucketCurrent = $this->bucketCurrent ?: $bucket[ 'bucket' ]; |
|
155 | - $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ], $bucket[ 'password' ])); |
|
154 | + $this->bucketCurrent = $this->bucketCurrent ?: $bucket['bucket']; |
|
155 | + $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'], $bucket['password'])); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | protected function getBucket() |
164 | 164 | { |
165 | - return $this->bucketInstances[ $this->bucketCurrent ]; |
|
165 | + return $this->bucketInstances[$this->bucketCurrent]; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | protected function setBucket($bucketName, \CouchbaseBucket $CouchbaseBucket) |
174 | 174 | { |
175 | 175 | if (!array_key_exists($bucketName, $this->bucketInstances)) { |
176 | - $this->bucketInstances[ $bucketName ] = $CouchbaseBucket; |
|
176 | + $this->bucketInstances[$bucketName] = $CouchbaseBucket; |
|
177 | 177 | } else { |
178 | 178 | throw new \LogicException('A bucket instance with this name already exists.'); |
179 | 179 | } |
@@ -212,6 +212,6 @@ discard block |
||
212 | 212 | ->setSize($info['basicStats']['diskUsed']) |
213 | 213 | ->setRawData($info) |
214 | 214 | ->setData(implode(', ', array_keys($this->itemInstances))) |
215 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][0]['version'] . ', Uptime (in days): ' . round($info[ 'nodes' ][0][ 'uptime' ] / 86400, 1). "\n For more information see RawData."); |
|
215 | + ->setInfo('CouchBase version ' . $info['nodes'][0]['version'] . ', Uptime (in days): ' . round($info['nodes'][0]['uptime'] / 86400, 1) . "\n For more information see RawData."); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | \ No newline at end of file |