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