Passed
Push — v7 ( 4b7cde...9c98f2 )
by Georges
02:08
created
lib/Phpfastcache/Drivers/Mongodb/Driver.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @author Fabio Covolo Mazzo (fabiocmazzo) <[email protected]>
13 13
  *
14 14
  */
15
-declare(strict_types=1);
15
+declare(strict_types = 1);
16 16
 
17 17
 namespace Phpfastcache\Drivers\Mongodb;
18 18
 
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
78 78
 
79 79
         if ($document) {
80 80
             $return = [
81
-              self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()),
82
-              self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()),
83
-              self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
81
+              self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->getData()),
82
+              self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->getData()),
83
+              self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_EDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()),
84 84
             ];
85 85
 
86
-            if(!empty($this->getConfigOption('itemDetailedDate'))){
86
+            if (!empty($this->getConfigOption('itemDetailedDate'))) {
87 87
                 $return += [
88
-                  self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_MDATE_WRAPPER_INDEX ]->toDateTime()
88
+                  self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_MDATE_WRAPPER_INDEX]->toDateTime()
89 89
                     ->getTimestamp()),
90
-                  self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_CDATE_WRAPPER_INDEX ]->toDateTime()
90
+                  self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_CDATE_WRAPPER_INDEX]->toDateTime()
91 91
                     ->getTimestamp()),
92 92
                 ];
93 93
             }
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
                   self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((\time() + $item->getTtl()) * 1000) : new UTCDateTime(\time() * 1000)),
118 118
                 ];
119 119
 
120
-                if(!empty($this->getConfigOption('itemDetailedDate'))){
120
+                if (!empty($this->getConfigOption('itemDetailedDate'))) {
121 121
                     $set += [
122 122
                       self::DRIVER_MDATE_WRAPPER_INDEX => ($item->getModificationDate() ? new UTCDateTime(($item->getModificationDate()->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)),
123 123
                       self::DRIVER_CDATE_WRAPPER_INDEX => ($item->getCreationDate() ? new UTCDateTime(($item->getCreationDate()->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)),
124 124
                     ];
125 125
                 }
126
-                $result = (array)$this->getCollection()->updateOne(
126
+                $result = (array) $this->getCollection()->updateOne(
127 127
                   ['_id' => $item->getEncodedKey()],
128 128
                   [
129 129
                     '$set' => $set,
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 throw new PhpfastcacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e);
135 135
             }
136 136
 
137
-            return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true;
137
+            return isset($result['ok']) ? $result['ok'] == 1 : true;
138 138
         }
139 139
 
140 140
         throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     {
226 226
         $host = $this->getConfigOption('host');
227 227
         $port = $this->getConfigOption('port');
228
-        $username =  $this->getConfigOption('username');
228
+        $username = $this->getConfigOption('username');
229 229
         $password = $this->getConfigOption('password');
230 230
 
231 231
         return implode('', [
@@ -263,14 +263,14 @@  discard block
 block discarded – undo
263 263
           'recordStats' => 0,
264 264
           'repl' => 0,
265 265
           'metrics' => 0,
266
-        ]))->toArray()[ 0 ];
266
+        ]))->toArray()[0];
267 267
 
268 268
         $collectionStats = $this->instance->getManager()->executeCommand('phpFastCache', new Command([
269
-          'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'),
269
+          'collStats' => (isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache'),
270 270
           'verbose' => true,
271
-        ]))->toArray()[ 0 ];
271
+        ]))->toArray()[0];
272 272
 
273
-        $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) {
273
+        $array_filter_recursive = function($array, callable $callback = null) use (&$array_filter_recursive) {
274 274
             $array = $callback($array);
275 275
 
276 276
             if (\is_object($array) || \is_array($array)) {
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
             return $array;
283 283
         };
284 284
 
285
-        $callback = function ($item) {
285
+        $callback = function($item) {
286 286
             /**
287 287
              * Remove unserializable properties
288 288
              */
289 289
             if ($item instanceof \MongoDB\BSON\UTCDateTime) {
290
-                return (string)$item;
290
+                return (string) $item;
291 291
             }
292 292
             return $item;
293 293
         };
Please login to merge, or discard this patch.