@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time() * 1000)), |
94 | 94 | ]; |
95 | 95 | |
96 | - if(!empty($this->config[ 'itemDetailedDate' ])){ |
|
96 | + if (!empty($this->config['itemDetailedDate'])) { |
|
97 | 97 | $set += [ |
98 | 98 | self::DRIVER_MDATE_WRAPPER_INDEX => ($item->getModificationDate() ? new UTCDateTime(($item->getModificationDate()->getTimestamp()) * 1000) : new UTCDateTime(time() * 1000)), |
99 | 99 | self::DRIVER_CDATE_WRAPPER_INDEX => ($item->getCreationDate() ? new UTCDateTime(($item->getCreationDate()->getTimestamp()) * 1000) : new UTCDateTime(time() * 1000)), |
100 | 100 | ]; |
101 | 101 | } |
102 | 102 | |
103 | - $result = (array)$this->getCollection()->updateOne( |
|
103 | + $result = (array) $this->getCollection()->updateOne( |
|
104 | 104 | ['_id' => $item->getEncodedKey()], |
105 | 105 | ['$set' => $set], |
106 | 106 | ['upsert' => true, 'multiple' => false] |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | throw new phpFastCacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e); |
110 | 110 | } |
111 | 111 | |
112 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
112 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
113 | 113 | } else { |
114 | 114 | throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected'); |
115 | 115 | } |
@@ -125,15 +125,15 @@ discard block |
||
125 | 125 | |
126 | 126 | if ($document) { |
127 | 127 | $return = [ |
128 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
129 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
130 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
128 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->getData()), |
|
129 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->getData()), |
|
130 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_EDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()), |
|
131 | 131 | ]; |
132 | 132 | |
133 | - if(!empty($this->config[ 'itemDetailedDate' ])){ |
|
133 | + if (!empty($this->config['itemDetailedDate'])) { |
|
134 | 134 | $return += [ |
135 | - self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_MDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
136 | - self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_CDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
135 | + self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_MDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()), |
|
136 | + self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_CDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()), |
|
137 | 137 | ]; |
138 | 138 | } |
139 | 139 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | */ |
182 | 182 | $this->save($this->getItem('__PFC_CACHE_CLEARED__')->set(true)); |
183 | 183 | |
184 | - return !empty($result[ 'ok' ]); |
|
184 | + return !empty($result['ok']); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -194,13 +194,13 @@ discard block |
||
194 | 194 | if ($this->instance instanceof \MongoDB\Driver\Manager) { |
195 | 195 | throw new LogicException('Already connected to Mongodb server'); |
196 | 196 | } else { |
197 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
198 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : '27017'; |
|
199 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 3; |
|
200 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
201 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
202 | - $collectionName = isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'; |
|
203 | - $databaseName = isset($this->config[ 'databaseName' ]) ? $this->config[ 'databaseName' ] : 'phpFastCache'; |
|
197 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
198 | + $port = isset($this->config['port']) ? $this->config['port'] : '27017'; |
|
199 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 3; |
|
200 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
201 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
202 | + $collectionName = isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache'; |
|
203 | + $databaseName = isset($this->config['databaseName']) ? $this->config['databaseName'] : 'phpFastCache'; |
|
204 | 204 | |
205 | 205 | |
206 | 206 | /** |
@@ -242,14 +242,14 @@ discard block |
||
242 | 242 | 'recordStats' => 0, |
243 | 243 | 'repl' => 0, |
244 | 244 | 'metrics' => 0, |
245 | - ]))->toArray()[ 0 ]; |
|
245 | + ]))->toArray()[0]; |
|
246 | 246 | |
247 | 247 | $collectionStats = $this->instance->executeCommand('phpFastCache', new Command([ |
248 | - 'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'), |
|
248 | + 'collStats' => (isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache'), |
|
249 | 249 | 'verbose' => true, |
250 | - ]))->toArray()[ 0 ]; |
|
250 | + ]))->toArray()[0]; |
|
251 | 251 | |
252 | - $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) { |
|
252 | + $array_filter_recursive = function($array, callable $callback = null) use (&$array_filter_recursive) { |
|
253 | 253 | $array = $callback($array); |
254 | 254 | |
255 | 255 | if (is_object($array) || is_array($array)) { |
@@ -261,12 +261,12 @@ discard block |
||
261 | 261 | return $array; |
262 | 262 | }; |
263 | 263 | |
264 | - $callback = function ($item) { |
|
264 | + $callback = function($item) { |
|
265 | 265 | /** |
266 | 266 | * Remove unserializable properties |
267 | 267 | */ |
268 | 268 | if ($item instanceof \MongoDB\BSON\UTCDateTime) { |
269 | - return (string)$item; |
|
269 | + return (string) $item; |
|
270 | 270 | } |
271 | 271 | return $item; |
272 | 272 | }; |