Completed
Push — V6 ( 799449...64bc5e )
by Georges
02:30
created
src/phpFastCache/Drivers/Mongodb/Driver.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.