@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | public function dispatch($eventName, ...$args) |
70 | 70 | { |
71 | 71 | $eventName = 'on' . ucfirst($eventName); |
72 | - if(array_key_exists($eventName, $this->events)){ |
|
73 | - foreach ($this->events[ $eventName ] as $event) { |
|
72 | + if (array_key_exists($eventName, $this->events)) { |
|
73 | + foreach ($this->events[$eventName] as $event) { |
|
74 | 74 | call_user_func_array($event, $args); |
75 | 75 | } |
76 | 76 | } |
@@ -84,17 +84,17 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function __call($name, $arguments) |
86 | 86 | { |
87 | - if(strpos($name, 'on') === 0){ |
|
88 | - if(is_callable($arguments[0])){ |
|
89 | - if(isset($arguments[1]) && is_string($arguments[0])){ |
|
87 | + if (strpos($name, 'on') === 0) { |
|
88 | + if (is_callable($arguments[0])) { |
|
89 | + if (isset($arguments[1]) && is_string($arguments[0])) { |
|
90 | 90 | $this->events[$name][$arguments[1]] = $arguments[0]; |
91 | - }else { |
|
91 | + } else { |
|
92 | 92 | $this->events[$name][] = $arguments[0]; |
93 | 93 | } |
94 | - }else{ |
|
94 | + } else { |
|
95 | 95 | throw new phpFastCacheInvalidArgumentException(sprintf('Expected Callable, got "%s"', gettype($arguments[0]))); |
96 | 96 | } |
97 | - }else{ |
|
97 | + } else { |
|
98 | 98 | throw new \BadMethodCallException('An event must start with "on" such as "onCacheGetItem"'); |
99 | 99 | } |
100 | 100 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function unbindEventCallback($eventName, $callbackName) |
108 | 108 | { |
109 | - if(isset($this->events[$eventName][$callbackName])){ |
|
109 | + if (isset($this->events[$eventName][$callbackName])) { |
|
110 | 110 | unset($this->events[$eventName][$callbackName]); |
111 | 111 | return true; |
112 | 112 | } |
@@ -88,13 +88,13 @@ |
||
88 | 88 | if(is_callable($arguments[0])){ |
89 | 89 | if(isset($arguments[1]) && is_string($arguments[0])){ |
90 | 90 | $this->events[$name][$arguments[1]] = $arguments[0]; |
91 | - }else { |
|
91 | + } else { |
|
92 | 92 | $this->events[$name][] = $arguments[0]; |
93 | 93 | } |
94 | - }else{ |
|
94 | + } else{ |
|
95 | 95 | throw new phpFastCacheInvalidArgumentException(sprintf('Expected Callable, got "%s"', gettype($arguments[0]))); |
96 | 96 | } |
97 | - }else{ |
|
97 | + } else{ |
|
98 | 98 | throw new \BadMethodCallException('An event must start with "on" such as "onCacheGetItem"'); |
99 | 99 | } |
100 | 100 | } |
@@ -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; |