Completed
Pull Request — final (#326)
by
unknown
03:12
created
src/phpFastCache/Drivers/Mongodb/Driver.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function driverCheck()
64 64
     {
65
-        if(!class_exists('MongoDB\Driver\Manager')){
65
+        if (!class_exists('MongoDB\Driver\Manager')) {
66 66
             trigger_error('This driver is used to support the pecl MongoDb extension with mongo-php-library.<br />
67 67
             For MongoDb with Mongo PECL support use Mongo Driver.', E_USER_ERROR);
68 68
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
                   ['_id' => $item->getKey()],
92 92
                   [
93 93
                     '$set' => [
94
-                      self::DRIVER_TIME_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time()*1000)),
94
+                      self::DRIVER_TIME_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time() * 1000)),
95 95
                       self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC),
96 96
                       self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC),
97 97
                     ],
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                 return false;
103 103
             }
104 104
 
105
-            return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true;
105
+            return isset($result['ok']) ? $result['ok'] == 1 : true;
106 106
         } else {
107 107
             throw new \InvalidArgumentException('Cross-Driver type confusion detected');
108 108
         }
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 
121 121
         if ($document) {
122 122
             return [
123
-              self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()),
124
-              self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
125
-              self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()),
123
+              self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->getData()),
124
+              self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_TIME_WRAPPER_INDEX]->toDateTime()->getTimestamp()),
125
+              self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->getData()),
126 126
             ];
127 127
         } else {
128 128
             return null;
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
         if ($this->instance instanceof MongodbClient) {
167 167
             throw new LogicException('Already connected to Mongodb server');
168 168
         } else {
169
-            $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1';
170
-            $port = isset($server[ 'port' ]) ? $server[ 'port' ] : '27017';
171
-            $timeout = isset($server[ 'timeout' ]) ? $server[ 'timeout' ] : 3;
172
-            $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : '';
173
-            $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : '';
169
+            $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1';
170
+            $port = isset($server['port']) ? $server['port'] : '27017';
171
+            $timeout = isset($server['timeout']) ? $server['timeout'] : 3;
172
+            $password = isset($this->config['password']) ? $this->config['password'] : '';
173
+            $username = isset($this->config['username']) ? $this->config['username'] : '';
174 174
 
175 175
 
176 176
             /**
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
               ($password ? ":{$password}" : '') .
182 182
               ($username ? '@' : '') . "{$host}" .
183 183
               ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]));
184
-              $this->collection = $this->collection ?: new Collection($this->instance,'phpFastCache','Cache'); 
184
+              $this->collection = $this->collection ?: new Collection($this->instance, 'phpFastCache', 'Cache'); 
185 185
          }
186 186
     }
187 187
 
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
         ]));
219 219
 
220 220
         $stats = (new driverStatistic())
221
-          ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.")
222
-          ->setSize((int) @$collStats[ 'size' ])
221
+          ->setInfo('MongoDB version ' . $serverStatus['version'] . ', Uptime (in days): ' . round($serverStatus['uptime'] / 86400, 1) . "\n For more information see RawData.")
222
+          ->setSize((int) @$collStats['size'])
223 223
           ->setData(implode(', ', array_keys($this->itemInstances)))
224 224
           ->setRawData([
225 225
             'serverStatus' => $serverStatus,
Please login to merge, or discard this patch.