@@ -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) |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | protected function driverRead(CacheItemInterface $item) |
81 | 81 | { |
82 | 82 | return [ |
83 | - self::DRIVER_DATA_WRAPPER_INDEX => false, |
|
84 | - self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
85 | - self::DRIVER_EDATE_WRAPPER_INDEX => new \DateTime(), |
|
83 | + self::DRIVER_DATA_WRAPPER_INDEX => false, |
|
84 | + self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
85 | + self::DRIVER_EDATE_WRAPPER_INDEX => new \DateTime(), |
|
86 | 86 | ]; |
87 | 87 | } |
88 | 88 | /** |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | { |
132 | 132 | $stat = new driverStatistic(); |
133 | 133 | $stat->setInfo('[Devfalse] A void info string') |
134 | - ->setSize(0) |
|
135 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
136 | - ->setRawData(false); |
|
134 | + ->setSize(0) |
|
135 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
136 | + ->setRawData(false); |
|
137 | 137 | |
138 | 138 | return $stat; |
139 | 139 | } |
@@ -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 | } |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | { |
49 | 49 | $keyHashFunction = $this->driver->getConfigOption('defaultKeyHashFunction'); |
50 | 50 | |
51 | - if($keyHashFunction){ |
|
51 | + if ($keyHashFunction) { |
|
52 | 52 | return $keyHashFunction($this->getKey()); |
53 | - }else{ |
|
53 | + } else { |
|
54 | 54 | return md5($this->getKey()); |
55 | 55 | } |
56 | 56 | } |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function getCreationDate() |
96 | 96 | { |
97 | - if($this->driver->getConfig()['itemDetailedDate']){ |
|
97 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
98 | 98 | return $this->creationDate; |
99 | - }else{ |
|
99 | + } else { |
|
100 | 100 | throw new \LogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.'); |
101 | 101 | } |
102 | 102 | } |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function setCreationDate(\DateTimeInterface $date) |
110 | 110 | { |
111 | - if($this->driver->getConfig()['itemDetailedDate']){ |
|
111 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
112 | 112 | $this->creationDate = $date; |
113 | 113 | return $this; |
114 | - }else{ |
|
114 | + } else { |
|
115 | 115 | throw new \LogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.'); |
116 | 116 | } |
117 | 117 | } |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function getModificationDate() |
124 | 124 | { |
125 | - if($this->driver->getConfig()['itemDetailedDate']){ |
|
125 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
126 | 126 | return $this->modificationDate; |
127 | - }else{ |
|
127 | + } else { |
|
128 | 128 | throw new \LogicException('Cannot access to the modification date when the "itemDetailedDate" configuration is disabled.'); |
129 | 129 | } |
130 | 130 | } |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function setModificationDate(\DateTimeInterface $date) |
138 | 138 | { |
139 | - if($this->driver->getConfig()['itemDetailedDate']){ |
|
139 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
140 | 140 | $this->modificationDate = $date; |
141 | 141 | return $this; |
142 | - }else{ |
|
142 | + } else { |
|
143 | 143 | throw new \LogicException('Cannot access to the modification date when the "itemDetailedDate" configuration is disabled.'); |
144 | 144 | } |
145 | 145 | } |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | public function removeTag($tagName) |
307 | 307 | { |
308 | 308 | if (($key = array_search($tagName, $this->tags)) !== false) { |
309 | - unset($this->tags[ $key ]); |
|
309 | + unset($this->tags[$key]); |
|
310 | 310 | $this->removedTags[] = $tagName; |
311 | 311 | } |
312 | 312 | |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | final public function __debugInfo() |
383 | 383 | { |
384 | 384 | $info = get_object_vars($this); |
385 | - $info[ 'driver' ] = 'object(' . get_class($info[ 'driver' ]) . ')'; |
|
385 | + $info['driver'] = 'object(' . get_class($info['driver']) . ')'; |
|
386 | 386 | |
387 | 387 | return (array) $info; |
388 | 388 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | if($keyHashFunction){ |
52 | 52 | return $keyHashFunction($this->getKey()); |
53 | - }else{ |
|
53 | + } else{ |
|
54 | 54 | return md5($this->getKey()); |
55 | 55 | } |
56 | 56 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | { |
97 | 97 | if($this->driver->getConfig()['itemDetailedDate']){ |
98 | 98 | return $this->creationDate; |
99 | - }else{ |
|
99 | + } else{ |
|
100 | 100 | throw new \LogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.'); |
101 | 101 | } |
102 | 102 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | if($this->driver->getConfig()['itemDetailedDate']){ |
112 | 112 | $this->creationDate = $date; |
113 | 113 | return $this; |
114 | - }else{ |
|
114 | + } else{ |
|
115 | 115 | throw new \LogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.'); |
116 | 116 | } |
117 | 117 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | { |
125 | 125 | if($this->driver->getConfig()['itemDetailedDate']){ |
126 | 126 | return $this->modificationDate; |
127 | - }else{ |
|
127 | + } else{ |
|
128 | 128 | throw new \LogicException('Cannot access to the modification date when the "itemDetailedDate" configuration is disabled.'); |
129 | 129 | } |
130 | 130 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | if($this->driver->getConfig()['itemDetailedDate']){ |
140 | 140 | $this->modificationDate = $date; |
141 | 141 | return $this; |
142 | - }else{ |
|
142 | + } else{ |
|
143 | 143 | throw new \LogicException('Cannot access to the modification date when the "itemDetailedDate" configuration is disabled.'); |
144 | 144 | } |
145 | 145 | } |
@@ -75,7 +75,7 @@ |
||
75 | 75 | |
76 | 76 | /** |
77 | 77 | * @param \Psr\Cache\CacheItemInterface $item |
78 | - * @return mixed |
|
78 | + * @return boolean |
|
79 | 79 | * @throws \InvalidArgumentException |
80 | 80 | * @throws phpFastCacheDriverException |
81 | 81 | */ |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | if ($item instanceof Item) { |
88 | 88 | try { |
89 | 89 | $result = (array) $this->getCollection()->updateOne( |
90 | - ['_id' => $item->getEncodedKey()], |
|
91 | - [ |
|
90 | + ['_id' => $item->getEncodedKey()], |
|
91 | + [ |
|
92 | 92 | '$set' => [ |
93 | - self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC), |
|
94 | - self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC), |
|
95 | - self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time()*1000)), |
|
93 | + self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC), |
|
94 | + self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC), |
|
95 | + self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time()*1000)), |
|
96 | 96 | ], |
97 | - ], |
|
98 | - ['upsert' => true, 'multiple' => false] |
|
97 | + ], |
|
98 | + ['upsert' => true, 'multiple' => false] |
|
99 | 99 | ); |
100 | 100 | } catch (MongoDBException $e) { |
101 | 101 | throw new phpFastCacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e); |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | |
118 | 118 | if ($document) { |
119 | 119 | return [ |
120 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
121 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
122 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
120 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
121 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
122 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
123 | 123 | ]; |
124 | 124 | } else { |
125 | 125 | return null; |
@@ -190,10 +190,10 @@ discard block |
||
190 | 190 | * @todo make an url builder |
191 | 191 | */ |
192 | 192 | $this->instance = $this->instance ?: (new MongodbManager('mongodb://' . |
193 | - ($username ?: '') . |
|
194 | - ($password ? ":{$password}" : '') . |
|
195 | - ($username ? '@' : '') . "{$host}" . |
|
196 | - ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000])); |
|
193 | + ($username ?: '') . |
|
194 | + ($password ? ":{$password}" : '') . |
|
195 | + ($username ? '@' : '') . "{$host}" . |
|
196 | + ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000])); |
|
197 | 197 | $this->collection = $this->collection ?: new Collection($this->instance,$databaseName, $collectionName); |
198 | 198 | |
199 | 199 | return true; |
@@ -221,15 +221,15 @@ discard block |
||
221 | 221 | public function getStats() |
222 | 222 | { |
223 | 223 | $serverStats = $this->instance->executeCommand('phpFastCache', new Command([ |
224 | - 'serverStatus' => 1, |
|
225 | - 'recordStats' => 0, |
|
226 | - 'repl' => 0, |
|
227 | - 'metrics' => 0, |
|
224 | + 'serverStatus' => 1, |
|
225 | + 'recordStats' => 0, |
|
226 | + 'repl' => 0, |
|
227 | + 'metrics' => 0, |
|
228 | 228 | ]))->toArray()[0]; |
229 | 229 | |
230 | 230 | $collectionStats = $this->instance->executeCommand('phpFastCache', new Command([ |
231 | - 'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'), |
|
232 | - 'verbose' => true, |
|
231 | + 'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'), |
|
232 | + 'verbose' => true, |
|
233 | 233 | ]))->toArray()[0]; |
234 | 234 | |
235 | 235 | $array_filter_recursive = function( $array, callable $callback = null ) use(&$array_filter_recursive) { |
@@ -259,13 +259,13 @@ 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, 1) . "\n For more information see RawData.") |
|
263 | - ->setSize($collectionStats->size) |
|
264 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
265 | - ->setRawData([ |
|
262 | + ->setInfo('MongoDB version ' . $serverStats->version . ', Uptime (in days): ' . round($serverStats->uptime / 86400, 1) . "\n For more information see RawData.") |
|
263 | + ->setSize($collectionStats->size) |
|
264 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
265 | + ->setRawData([ |
|
266 | 266 | 'serverStatus' => $serverStats, |
267 | 267 | 'collStats' => $collectionStats, |
268 | - ]); |
|
268 | + ]); |
|
269 | 269 | |
270 | 270 | return $stats; |
271 | 271 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function driverCheck() |
67 | 67 | { |
68 | - if(!class_exists('MongoDB\Driver\Manager') && class_exists('MongoClient')){ |
|
68 | + if (!class_exists('MongoDB\Driver\Manager') && class_exists('MongoClient')) { |
|
69 | 69 | trigger_error('This driver is used to support the pecl MongoDb extension with mongo-php-library. |
70 | 70 | For MongoDb with Mongo PECL support use Mongo Driver.', E_USER_ERROR); |
71 | 71 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | '$set' => [ |
93 | 93 | self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC), |
94 | 94 | self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC), |
95 | - self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time()*1000)), |
|
95 | + self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time() * 1000)), |
|
96 | 96 | ], |
97 | 97 | ], |
98 | 98 | ['upsert' => true, 'multiple' => false] |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | throw new phpFastCacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e); |
102 | 102 | } |
103 | 103 | |
104 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
104 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
105 | 105 | } else { |
106 | 106 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
107 | 107 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | |
118 | 118 | if ($document) { |
119 | 119 | return [ |
120 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
121 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
122 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
120 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->getData()), |
|
121 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->getData()), |
|
122 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_EDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()), |
|
123 | 123 | ]; |
124 | 124 | } else { |
125 | 125 | return null; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @var \MongoDB\Model\BSONDocument $result |
158 | 158 | */ |
159 | 159 | $result = $this->getCollection()->drop()->getArrayCopy(); |
160 | - $this->collection = new Collection($this->instance,'phpFastCache','Cache'); |
|
160 | + $this->collection = new Collection($this->instance, 'phpFastCache', 'Cache'); |
|
161 | 161 | |
162 | 162 | /** |
163 | 163 | * This will rebuild automatically the Collection indexes |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | if ($this->instance instanceof \MongoDB\Driver\Manager) { |
178 | 178 | throw new LogicException('Already connected to Mongodb server'); |
179 | 179 | } else { |
180 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
181 | - $port = isset($server[ 'port' ]) ? $server[ 'port' ] : '27017'; |
|
182 | - $timeout = isset($server[ 'timeout' ]) ? $server[ 'timeout' ] : 3; |
|
183 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
184 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
185 | - $collectionName = isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'; |
|
186 | - $databaseName = isset($this->config[ 'databaseName' ]) ? $this->config[ 'databaseName' ] : 'phpFastCache'; |
|
180 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
181 | + $port = isset($server['port']) ? $server['port'] : '27017'; |
|
182 | + $timeout = isset($server['timeout']) ? $server['timeout'] : 3; |
|
183 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
184 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
185 | + $collectionName = isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache'; |
|
186 | + $databaseName = isset($this->config['databaseName']) ? $this->config['databaseName'] : 'phpFastCache'; |
|
187 | 187 | |
188 | 188 | |
189 | 189 | /** |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | ($password ? ":{$password}" : '') . |
195 | 195 | ($username ? '@' : '') . "{$host}" . |
196 | 196 | ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000])); |
197 | - $this->collection = $this->collection ?: new Collection($this->instance,$databaseName, $collectionName); |
|
197 | + $this->collection = $this->collection ?: new Collection($this->instance, $databaseName, $collectionName); |
|
198 | 198 | |
199 | 199 | return true; |
200 | 200 | } |
@@ -228,16 +228,16 @@ discard block |
||
228 | 228 | ]))->toArray()[0]; |
229 | 229 | |
230 | 230 | $collectionStats = $this->instance->executeCommand('phpFastCache', new Command([ |
231 | - 'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'), |
|
231 | + 'collStats' => (isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache'), |
|
232 | 232 | 'verbose' => true, |
233 | 233 | ]))->toArray()[0]; |
234 | 234 | |
235 | - $array_filter_recursive = function( $array, callable $callback = null ) use(&$array_filter_recursive) { |
|
235 | + $array_filter_recursive = function($array, callable $callback = null) use(&$array_filter_recursive) { |
|
236 | 236 | $array = $callback($array); |
237 | 237 | |
238 | - if(is_object($array) ||is_array($array)){ |
|
239 | - foreach ( $array as &$value ) { |
|
240 | - $value = call_user_func( $array_filter_recursive, $value, $callback ); |
|
238 | + if (is_object($array) || is_array($array)) { |
|
239 | + foreach ($array as &$value) { |
|
240 | + $value = call_user_func($array_filter_recursive, $value, $callback); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | /** |
250 | 250 | * Remove unserializable properties |
251 | 251 | */ |
252 | - if($item instanceof \MongoDB\BSON\UTCDateTime){ |
|
252 | + if ($item instanceof \MongoDB\BSON\UTCDateTime) { |
|
253 | 253 | return (string) $item; |
254 | 254 | } |
255 | 255 | return $item; |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | $url .= $path; |
174 | 174 | |
175 | 175 | $this->instance = CouchDBClient::create([ |
176 | - 'dbname' => $this->getDatabaseName(), |
|
177 | - 'url' => $url, |
|
178 | - 'timeout' => $timeout |
|
176 | + 'dbname' => $this->getDatabaseName(), |
|
177 | + 'url' => $url, |
|
178 | + 'timeout' => $timeout |
|
179 | 179 | ]); |
180 | 180 | |
181 | 181 | $this->createDatabase(); |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | $path = '/' . $this->getDatabaseName() . '/' . urlencode($docId); |
193 | 193 | |
194 | 194 | $response = $this->instance->getHttpClient()->request( |
195 | - 'GET',// At this moment HEAD requests are not working: https://github.com/doctrine/couchdb-client/issues/72 |
|
196 | - $path, |
|
197 | - null, |
|
198 | - false |
|
195 | + 'GET',// At this moment HEAD requests are not working: https://github.com/doctrine/couchdb-client/issues/72 |
|
196 | + $path, |
|
197 | + null, |
|
198 | + false |
|
199 | 199 | ); |
200 | 200 | if(!empty($response->headers['etag'])){ |
201 | 201 | return trim($response->headers['etag'], " '\"\t\n\r\0\x0B"); |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | $info = $this->instance->getDatabaseInfo(); |
237 | 237 | |
238 | 238 | return (new driverStatistic()) |
239 | - ->setSize($info['sizes']['active']) |
|
240 | - ->setRawData($info) |
|
241 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
242 | - ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData."); |
|
239 | + ->setSize($info['sizes']['active']) |
|
240 | + ->setRawData($info) |
|
241 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
242 | + ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData."); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | \ No newline at end of file |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * Check for Cross-Driver type confusion |
70 | 70 | */ |
71 | 71 | if ($item instanceof Item) { |
72 | - try{ |
|
72 | + try { |
|
73 | 73 | $this->instance->putDocument(['data' => $this->encode($this->driverPreWrap($item))], $item->getEncodedKey(), $this->getLatestDocumentRevision($item->getEncodedKey())); |
74 | - }catch (CouchDBException $e){ |
|
74 | + } catch (CouchDBException $e) { |
|
75 | 75 | throw new phpFastCacheDriverException('Got error while trying to upsert a document: ' . $e->getMessage(), null, $e); |
76 | 76 | } |
77 | 77 | return true; |
@@ -87,17 +87,17 @@ discard block |
||
87 | 87 | */ |
88 | 88 | protected function driverRead(CacheItemInterface $item) |
89 | 89 | { |
90 | - try{ |
|
90 | + try { |
|
91 | 91 | $response = $this->instance->findDocument($item->getEncodedKey()); |
92 | - }catch (CouchDBException $e){ |
|
92 | + } catch (CouchDBException $e) { |
|
93 | 93 | throw new phpFastCacheDriverException('Got error while trying to get a document: ' . $e->getMessage(), null, $e); |
94 | 94 | } |
95 | 95 | |
96 | - if($response->status === 404 || empty($response->body['data'])){ |
|
96 | + if ($response->status === 404 || empty($response->body['data'])) { |
|
97 | 97 | return null; |
98 | - }else if($response->status === 200){ |
|
98 | + } else if ($response->status === 200) { |
|
99 | 99 | return $this->decode($response->body['data']); |
100 | - }else{ |
|
100 | + } else { |
|
101 | 101 | throw new phpFastCacheDriverException('Got unexpected HTTP status: ' . $response->status); |
102 | 102 | } |
103 | 103 | } |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | * Check for Cross-Driver type confusion |
115 | 115 | */ |
116 | 116 | if ($item instanceof Item) { |
117 | - try{ |
|
117 | + try { |
|
118 | 118 | $this->instance->deleteDocument($item->getEncodedKey(), $this->getLatestDocumentRevision($item->getEncodedKey())); |
119 | - }catch (CouchDBException $e){ |
|
119 | + } catch (CouchDBException $e) { |
|
120 | 120 | throw new phpFastCacheDriverException('Got error while trying to delete a document: ' . $e->getMessage(), null, $e); |
121 | 121 | } |
122 | 122 | return true; |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | */ |
132 | 132 | protected function driverClear() |
133 | 133 | { |
134 | - try{ |
|
134 | + try { |
|
135 | 135 | $this->instance->deleteDatabase($this->getDatabaseName()); |
136 | 136 | $this->createDatabase(); |
137 | - }catch (CouchDBException $e){ |
|
137 | + } catch (CouchDBException $e) { |
|
138 | 138 | throw new phpFastCacheDriverException('Got error while trying to delete and recreate the database: ' . $e->getMessage(), null, $e); |
139 | 139 | } |
140 | 140 | |
@@ -150,19 +150,19 @@ discard block |
||
150 | 150 | if ($this->instance instanceof CouchdbClient) { |
151 | 151 | throw new \LogicException('Already connected to Couchdb server'); |
152 | 152 | } else { |
153 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
154 | - $ssl = isset($this->config[ 'ssl' ]) ? $this->config[ 'ssl' ] : false; |
|
155 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : 5984; |
|
156 | - $path = isset($this->config[ 'path' ]) ? $this->config[ 'path' ] : '/'; |
|
157 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
158 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
159 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 10; |
|
153 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
154 | + $ssl = isset($this->config['ssl']) ? $this->config['ssl'] : false; |
|
155 | + $port = isset($this->config['port']) ? $this->config['port'] : 5984; |
|
156 | + $path = isset($this->config['path']) ? $this->config['path'] : '/'; |
|
157 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
158 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
159 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 10; |
|
160 | 160 | |
161 | 161 | $url = ($ssl ? 'https://' : 'http://'); |
162 | - if($username) |
|
162 | + if ($username) |
|
163 | 163 | { |
164 | 164 | $url .= "{$username}"; |
165 | - if($password) |
|
165 | + if ($password) |
|
166 | 166 | { |
167 | 167 | $url .= ":{$password}"; |
168 | 168 | } |
@@ -192,14 +192,14 @@ discard block |
||
192 | 192 | $path = '/' . $this->getDatabaseName() . '/' . urlencode($docId); |
193 | 193 | |
194 | 194 | $response = $this->instance->getHttpClient()->request( |
195 | - 'GET',// At this moment HEAD requests are not working: https://github.com/doctrine/couchdb-client/issues/72 |
|
195 | + 'GET', // At this moment HEAD requests are not working: https://github.com/doctrine/couchdb-client/issues/72 |
|
196 | 196 | $path, |
197 | 197 | null, |
198 | 198 | false |
199 | 199 | ); |
200 | - if(!empty($response->headers['etag'])){ |
|
200 | + if (!empty($response->headers['etag'])) { |
|
201 | 201 | return trim($response->headers['etag'], " '\"\t\n\r\0\x0B"); |
202 | - }else{ |
|
202 | + } else { |
|
203 | 203 | return null; |
204 | 204 | } |
205 | 205 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | protected function getDatabaseName() |
211 | 211 | { |
212 | - return isset($this->config[ 'database' ]) ? $this->config[ 'database' ] : 'phpfastcache'; |
|
212 | + return isset($this->config['database']) ? $this->config['database'] : 'phpfastcache'; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function createDatabase() |
219 | 219 | { |
220 | - if(!in_array($this->instance->getDatabase(), $this->instance->getAllDatabases(), true)){ |
|
220 | + if (!in_array($this->instance->getDatabase(), $this->instance->getAllDatabases(), true)) { |
|
221 | 221 | $this->instance->createDatabase($this->instance->getDatabase()); |
222 | 222 | } |
223 | 223 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if ($item instanceof Item) { |
72 | 72 | try{ |
73 | 73 | $this->instance->putDocument(['data' => $this->encode($this->driverPreWrap($item))], $item->getEncodedKey(), $this->getLatestDocumentRevision($item->getEncodedKey())); |
74 | - }catch (CouchDBException $e){ |
|
74 | + } catch (CouchDBException $e){ |
|
75 | 75 | throw new phpFastCacheDriverException('Got error while trying to upsert a document: ' . $e->getMessage(), null, $e); |
76 | 76 | } |
77 | 77 | return true; |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | { |
90 | 90 | try{ |
91 | 91 | $response = $this->instance->findDocument($item->getEncodedKey()); |
92 | - }catch (CouchDBException $e){ |
|
92 | + } catch (CouchDBException $e){ |
|
93 | 93 | throw new phpFastCacheDriverException('Got error while trying to get a document: ' . $e->getMessage(), null, $e); |
94 | 94 | } |
95 | 95 | |
96 | 96 | if($response->status === 404 || empty($response->body['data'])){ |
97 | 97 | return null; |
98 | - }else if($response->status === 200){ |
|
98 | + } else if($response->status === 200){ |
|
99 | 99 | return $this->decode($response->body['data']); |
100 | - }else{ |
|
100 | + } else{ |
|
101 | 101 | throw new phpFastCacheDriverException('Got unexpected HTTP status: ' . $response->status); |
102 | 102 | } |
103 | 103 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | if ($item instanceof Item) { |
117 | 117 | try{ |
118 | 118 | $this->instance->deleteDocument($item->getEncodedKey(), $this->getLatestDocumentRevision($item->getEncodedKey())); |
119 | - }catch (CouchDBException $e){ |
|
119 | + } catch (CouchDBException $e){ |
|
120 | 120 | throw new phpFastCacheDriverException('Got error while trying to delete a document: ' . $e->getMessage(), null, $e); |
121 | 121 | } |
122 | 122 | return true; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | try{ |
135 | 135 | $this->instance->deleteDatabase($this->getDatabaseName()); |
136 | 136 | $this->createDatabase(); |
137 | - }catch (CouchDBException $e){ |
|
137 | + } catch (CouchDBException $e){ |
|
138 | 138 | throw new phpFastCacheDriverException('Got error while trying to delete and recreate the database: ' . $e->getMessage(), null, $e); |
139 | 139 | } |
140 | 140 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | ); |
200 | 200 | if(!empty($response->headers['etag'])){ |
201 | 201 | return trim($response->headers['etag'], " '\"\t\n\r\0\x0B"); |
202 | - }else{ |
|
202 | + } else{ |
|
203 | 203 | return null; |
204 | 204 | } |
205 | 205 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function printNewLine($count = 1) |
97 | 97 | { |
98 | - for($i = 0; $i < $count; $i++){ |
|
98 | + for ($i = 0; $i < $count; $i++) { |
|
99 | 99 | print PHP_EOL; |
100 | 100 | } |
101 | 101 | |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function printText($string, $strtoupper = false) |
111 | 111 | { |
112 | - if(!$strtoupper){ |
|
112 | + if (!$strtoupper) { |
|
113 | 113 | print trim($string) . PHP_EOL; |
114 | - }else{ |
|
114 | + } else { |
|
115 | 115 | print strtoupper(trim($string) . PHP_EOL); |
116 | 116 | } |
117 | 117 | |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function runAsyncProcess($cmd) |
125 | 125 | { |
126 | - if (substr(php_uname(), 0, 7) === 'Windows'){ |
|
127 | - pclose(popen('start /B '. $cmd, 'r')); |
|
126 | + if (substr(php_uname(), 0, 7) === 'Windows') { |
|
127 | + pclose(popen('start /B ' . $cmd, 'r')); |
|
128 | 128 | } |
129 | 129 | else { |
130 | 130 | exec($cmd . ' > /dev/null &'); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | { |
112 | 112 | if(!$strtoupper){ |
113 | 113 | print trim($string) . PHP_EOL; |
114 | - }else{ |
|
114 | + } else{ |
|
115 | 115 | print strtoupper(trim($string) . PHP_EOL); |
116 | 116 | } |
117 | 117 | |
@@ -125,8 +125,7 @@ discard block |
||
125 | 125 | { |
126 | 126 | if (substr(php_uname(), 0, 7) === 'Windows'){ |
127 | 127 | pclose(popen('start /B '. $cmd, 'r')); |
128 | - } |
|
129 | - else { |
|
128 | + } else { |
|
130 | 129 | exec($cmd . ' > /dev/null &'); |
131 | 130 | } |
132 | 131 | } |
@@ -39,10 +39,10 @@ |
||
39 | 39 | */ |
40 | 40 | public function __construct($itemKey, \DateTime $itemDate) |
41 | 41 | { |
42 | - if(is_string($itemKey)){ |
|
42 | + if (is_string($itemKey)) { |
|
43 | 43 | $this->itemKey = $itemKey; |
44 | 44 | $this->itemDate = $itemDate; |
45 | - }else{ |
|
45 | + } else { |
|
46 | 46 | throw new phpFastCacheInvalidArgumentException(sprintf('$itemKey must be a string, got "%s" instead', gettype($itemKey))); |
47 | 47 | } |
48 | 48 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | if(is_string($itemKey)){ |
43 | 43 | $this->itemKey = $itemKey; |
44 | 44 | $this->itemDate = $itemDate; |
45 | - }else{ |
|
45 | + } else{ |
|
46 | 46 | throw new phpFastCacheInvalidArgumentException(sprintf('$itemKey must be a string, got "%s" instead', gettype($itemKey))); |
47 | 47 | } |
48 | 48 | } |