Completed
Pull Request — final (#592)
by Georges
03:52
created
src/phpFastCache/Drivers/Cassandra/Driver.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
             try {
76 76
                 $cacheData = $this->encode($this->driverPreWrap($item));
77 77
                 $options = new Cassandra\ExecutionOptions([
78
-                  'arguments' => [
78
+                    'arguments' => [
79 79
                     'cache_uuid' => new Cassandra\Uuid(),
80 80
                     'cache_id' => $item->getKey(),
81 81
                     'cache_data' => $cacheData,
82 82
                     'cache_creation_date' => new Cassandra\Timestamp((new \DateTime())->getTimestamp()),
83 83
                     'cache_expiration_date' => new Cassandra\Timestamp($item->getExpirationDate()->getTimestamp()),
84 84
                     'cache_length' => strlen($cacheData),
85
-                  ],
86
-                  'consistency' => Cassandra::CONSISTENCY_ALL,
87
-                  'serial_consistency' => Cassandra::CONSISTENCY_SERIAL,
85
+                    ],
86
+                    'consistency' => Cassandra::CONSISTENCY_ALL,
87
+                    'serial_consistency' => Cassandra::CONSISTENCY_SERIAL,
88 88
                 ]);
89 89
 
90 90
                 $query = sprintf('INSERT INTO %s.%s
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
     {
123 123
         try {
124 124
             $options = new Cassandra\ExecutionOptions([
125
-              'arguments' => ['cache_id' => $item->getKey()],
126
-              'page_size' => 1,
125
+                'arguments' => ['cache_id' => $item->getKey()],
126
+                'page_size' => 1,
127 127
             ]);
128 128
             $query = sprintf(
129
-              'SELECT cache_data FROM %s.%s WHERE cache_id = :cache_id;',
130
-              self::CASSANDRA_KEY_SPACE,
131
-              self::CASSANDRA_TABLE
129
+                'SELECT cache_data FROM %s.%s WHERE cache_id = :cache_id;',
130
+                self::CASSANDRA_KEY_SPACE,
131
+                self::CASSANDRA_TABLE
132 132
             );
133 133
             $results = $this->instance->execute(new Cassandra\SimpleStatement($query), $options);
134 134
 
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
         if ($item instanceof Item) {
156 156
             try {
157 157
                 $options = new Cassandra\ExecutionOptions([
158
-                  'arguments' => [
158
+                    'arguments' => [
159 159
                     'cache_id' => $item->getKey(),
160
-                  ],
160
+                    ],
161 161
                 ]);
162 162
                 $result = $this->instance->execute(new Cassandra\SimpleStatement(sprintf(
163
-                  'DELETE FROM %s.%s WHERE cache_id = :cache_id;',
164
-                  self::CASSANDRA_KEY_SPACE,
165
-                  self::CASSANDRA_TABLE
163
+                    'DELETE FROM %s.%s WHERE cache_id = :cache_id;',
164
+                    self::CASSANDRA_KEY_SPACE,
165
+                    self::CASSANDRA_TABLE
166 166
                 )), $options);
167 167
 
168 168
                 /**
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
     {
187 187
         try {
188 188
             $this->instance->execute(new Cassandra\SimpleStatement(sprintf(
189
-              'TRUNCATE %s.%s;',
190
-              self::CASSANDRA_KEY_SPACE, self::CASSANDRA_TABLE
189
+                'TRUNCATE %s.%s;',
190
+                self::CASSANDRA_KEY_SPACE, self::CASSANDRA_TABLE
191 191
             )));
192 192
 
193 193
             return true;
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
             $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : '';
214 214
 
215 215
             $clusterBuilder = Cassandra::cluster()
216
-              ->withContactPoints($host)
217
-              ->withPort($port);
216
+                ->withContactPoints($host)
217
+                ->withPort($port);
218 218
 
219 219
             if (!empty($this->config[ 'ssl' ][ 'enabled' ])) {
220 220
                 if (!empty($this->config[ 'ssl' ][ 'verify' ])) {
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
              */
243 243
 
244 244
             $this->instance->execute(new Cassandra\SimpleStatement(sprintf(
245
-              "CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };",
246
-              self::CASSANDRA_KEY_SPACE
245
+                "CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };",
246
+                self::CASSANDRA_KEY_SPACE
247 247
             )));
248 248
             $this->instance->execute(new Cassandra\SimpleStatement(sprintf('USE %s;', self::CASSANDRA_KEY_SPACE)));
249 249
             $this->instance->execute(new Cassandra\SimpleStatement(sprintf('
@@ -290,15 +290,15 @@  discard block
 block discarded – undo
290 290
     public function getStats()
291 291
     {
292 292
         $result = $this->instance->execute(new Cassandra\SimpleStatement(sprintf(
293
-          'SELECT SUM(cache_length) as cache_size FROM %s.%s',
294
-          self::CASSANDRA_KEY_SPACE,
295
-          self::CASSANDRA_TABLE
293
+            'SELECT SUM(cache_length) as cache_size FROM %s.%s',
294
+            self::CASSANDRA_KEY_SPACE,
295
+            self::CASSANDRA_TABLE
296 296
         )));
297 297
 
298 298
         return (new DriverStatistic())
299
-          ->setSize($result->first()[ 'cache_size' ])
300
-          ->setRawData([])
301
-          ->setData(implode(', ', array_keys($this->itemInstances)))
302
-          ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.');
299
+            ->setSize($result->first()[ 'cache_size' ])
300
+            ->setRawData([])
301
+            ->setData(implode(', ', array_keys($this->itemInstances)))
302
+            ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.');
303 303
     }
304 304
 }
305 305
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             $results = $this->instance->execute(new Cassandra\SimpleStatement($query), $options);
134 134
 
135 135
             if ($results instanceof Cassandra\Rows && $results->count() === 1) {
136
-                return $this->decode($results->first()[ 'cache_data' ]);
136
+                return $this->decode($results->first()['cache_data']);
137 137
             } else {
138 138
                 return null;
139 139
             }
@@ -206,18 +206,18 @@  discard block
 block discarded – undo
206 206
         if ($this->instance instanceof CassandraSession) {
207 207
             throw new phpFastCacheLogicException('Already connected to Couchbase server');
208 208
         } else {
209
-            $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1';
210
-            $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : 9042;
211
-            $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 2;
212
-            $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : '';
213
-            $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : '';
209
+            $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1';
210
+            $port = isset($this->config['port']) ? $this->config['port'] : 9042;
211
+            $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 2;
212
+            $password = isset($this->config['password']) ? $this->config['password'] : '';
213
+            $username = isset($this->config['username']) ? $this->config['username'] : '';
214 214
 
215 215
             $clusterBuilder = Cassandra::cluster()
216 216
               ->withContactPoints($host)
217 217
               ->withPort($port);
218 218
 
219
-            if (!empty($this->config[ 'ssl' ][ 'enabled' ])) {
220
-                if (!empty($this->config[ 'ssl' ][ 'verify' ])) {
219
+            if (!empty($this->config['ssl']['enabled'])) {
220
+                if (!empty($this->config['ssl']['verify'])) {
221 221
                     $sslBuilder = Cassandra::ssl()->withVerifyFlags(Cassandra::VERIFY_PEER_CERT);
222 222
                 } else {
223 223
                     $sslBuilder = Cassandra::ssl()->withVerifyFlags(Cassandra::VERIFY_NONE);
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
         )));
297 297
 
298 298
         return (new DriverStatistic())
299
-          ->setSize($result->first()[ 'cache_size' ])
299
+          ->setSize($result->first()['cache_size'])
300 300
           ->setRawData([])
301 301
           ->setData(implode(', ', array_keys($this->itemInstances)))
302 302
           ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.');
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Files/Driver.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
     /**
62 62
      * @param \Psr\Cache\CacheItemInterface $item
63
-     * @return mixed
63
+     * @return boolean
64 64
      * @throws phpFastCacheInvalidArgumentException
65 65
      */
66 66
     protected function driverWrite(CacheItemInterface $item)
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     /**
147 147
      * @param string $optionName
148 148
      * @param mixed $optionValue
149
-     * @return bool
149
+     * @return boolean|null
150 150
      * @throws phpFastCacheInvalidArgumentException
151 151
      */
152 152
     public static function isValidOption($optionName, $optionValue)
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     }
180 180
 
181 181
     /**
182
-     * @return array
182
+     * @return string[]
183 183
      */
184 184
     public static function getValidOptions()
185 185
     {
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     }
188 188
 
189 189
     /**
190
-     * @return array
190
+     * @return string[]
191 191
      */
192 192
     public static function getRequiredOptions()
193 193
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
              * Force write
77 77
              */
78 78
             try {
79
-                return $this->writefile($file_path, $data, $this->config[ 'secureFileManipulation' ]);
79
+                return $this->writefile($file_path, $data, $this->config['secureFileManipulation']);
80 80
             } catch (\Exception $e) {
81 81
                 return false;
82 82
             }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     protected function driverClear()
138 138
     {
139
-        return (bool)Directory::rrmdir($this->getPath(true));
139
+        return (bool) Directory::rrmdir($this->getPath(true));
140 140
     }
141 141
 
142 142
     /**
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Cookie/Item.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Devfalse/Driver.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
     protected function driverRead(CacheItemInterface $item)
77 77
     {
78 78
         return [
79
-          self::DRIVER_DATA_WRAPPER_INDEX => false,
80
-          self::DRIVER_TAGS_WRAPPER_INDEX => [],
81
-          self::DRIVER_EDATE_WRAPPER_INDEX => new \DateTime(),
79
+            self::DRIVER_DATA_WRAPPER_INDEX => false,
80
+            self::DRIVER_TAGS_WRAPPER_INDEX => [],
81
+            self::DRIVER_EDATE_WRAPPER_INDEX => new \DateTime(),
82 82
         ];
83 83
     }
84 84
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
     {
129 129
         $stat = new DriverStatistic();
130 130
         $stat->setInfo('[Devfalse] A void info string')
131
-          ->setSize(0)
132
-          ->setData(implode(', ', array_keys($this->itemInstances)))
133
-          ->setRawData(false);
131
+            ->setSize(0)
132
+            ->setData(implode(', ', array_keys($this->itemInstances)))
133
+            ->setRawData(false);
134 134
 
135 135
         return $stat;
136 136
     }
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Devnull/Driver.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -127,9 +127,9 @@
 block discarded – undo
127 127
     {
128 128
         $stat = new DriverStatistic();
129 129
         $stat->setInfo('[Devnull] A void info string')
130
-          ->setSize(0)
131
-          ->setData(implode(', ', array_keys($this->itemInstances)))
132
-          ->setRawData(null);
130
+            ->setSize(0)
131
+            ->setData(implode(', ', array_keys($this->itemInstances)))
132
+            ->setRawData(null);
133 133
 
134 134
         return $stat;
135 135
     }
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Devtrue/Driver.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Mongodb/Driver.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
 
77 77
     /**
78 78
      * @param \Psr\Cache\CacheItemInterface $item
79
-     * @return mixed
79
+     * @return boolean
80 80
      * @throws phpFastCacheInvalidArgumentException
81 81
      * @throws phpFastCacheDriverException
82 82
      */
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -96,22 +96,22 @@  discard block
 block discarded – undo
96 96
         if ($item instanceof Item) {
97 97
             try {
98 98
                 $set = [
99
-                  self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC),
100
-                  self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC),
101
-                  self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time() * 1000)),
99
+                    self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC),
100
+                    self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC),
101
+                    self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time() * 1000)),
102 102
                 ];
103 103
 
104 104
                 if(!empty($this->config[ 'itemDetailedDate' ])){
105 105
                     $set += [
106
-                      self::DRIVER_MDATE_WRAPPER_INDEX => ($item->getModificationDate() ? new UTCDateTime(($item->getModificationDate()->getTimestamp()) * 1000) : new UTCDateTime(time() * 1000)),
107
-                      self::DRIVER_CDATE_WRAPPER_INDEX => ($item->getCreationDate() ? new UTCDateTime(($item->getCreationDate()->getTimestamp()) * 1000) : new UTCDateTime(time() * 1000)),
106
+                        self::DRIVER_MDATE_WRAPPER_INDEX => ($item->getModificationDate() ? new UTCDateTime(($item->getModificationDate()->getTimestamp()) * 1000) : new UTCDateTime(time() * 1000)),
107
+                        self::DRIVER_CDATE_WRAPPER_INDEX => ($item->getCreationDate() ? new UTCDateTime(($item->getCreationDate()->getTimestamp()) * 1000) : new UTCDateTime(time() * 1000)),
108 108
                     ];
109 109
                 }
110 110
 
111 111
                 $result = (array)$this->getCollection()->updateOne(
112
-                  ['_id' => $item->getEncodedKey()],
113
-                  ['$set' => $set],
114
-                  ['upsert' => true, 'multiple' => false]
112
+                    ['_id' => $item->getEncodedKey()],
113
+                    ['$set' => $set],
114
+                    ['upsert' => true, 'multiple' => false]
115 115
                 );
116 116
             } catch (MongoDBException $e) {
117 117
                 throw new phpFastCacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e);
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
 
134 134
         if ($document) {
135 135
             $return = [
136
-              self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()),
137
-              self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()),
138
-              self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
136
+                self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()),
137
+                self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()),
138
+                self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
139 139
             ];
140 140
 
141 141
             if(!empty($this->config[ 'itemDetailedDate' ])){
142 142
                 $return += [
143
-                  self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_MDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
144
-                  self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_CDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
143
+                    self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_MDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
144
+                    self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_CDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
145 145
                 ];
146 146
             }
147 147
 
@@ -281,15 +281,15 @@  discard block
 block discarded – undo
281 281
     public function getStats()
282 282
     {
283 283
         $serverStats = $this->instance->getManager()->executeCommand('phpFastCache', new Command([
284
-          'serverStatus' => 1,
285
-          'recordStats' => 0,
286
-          'repl' => 0,
287
-          'metrics' => 0,
284
+            'serverStatus' => 1,
285
+            'recordStats' => 0,
286
+            'repl' => 0,
287
+            'metrics' => 0,
288 288
         ]))->toArray()[ 0 ];
289 289
 
290 290
         $collectionStats = $this->instance->getManager()->executeCommand('phpFastCache', new Command([
291
-          'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'),
292
-          'verbose' => true,
291
+            'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'),
292
+            'verbose' => true,
293 293
         ]))->toArray()[ 0 ];
294 294
 
295 295
         $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) {
@@ -318,14 +318,14 @@  discard block
 block discarded – undo
318 318
         $collectionStats = $array_filter_recursive($collectionStats, $callback);
319 319
 
320 320
         $stats = (new DriverStatistic())
321
-          ->setInfo('MongoDB version ' . $serverStats->version . ', Uptime (in days): ' . round($serverStats->uptime / 86400,
322
-              1) . "\n For more information see RawData.")
323
-          ->setSize($collectionStats->size)
324
-          ->setData(implode(', ', array_keys($this->itemInstances)))
325
-          ->setRawData([
321
+            ->setInfo('MongoDB version ' . $serverStats->version . ', Uptime (in days): ' . round($serverStats->uptime / 86400,
322
+                1) . "\n For more information see RawData.")
323
+            ->setSize($collectionStats->size)
324
+            ->setData(implode(', ', array_keys($this->itemInstances)))
325
+            ->setRawData([
326 326
             'serverStatus' => $serverStats,
327 327
             'collStats' => $collectionStats,
328
-          ]);
328
+            ]);
329 329
 
330 330
         return $stats;
331 331
     }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
                   self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time() * 1000)),
102 102
                 ];
103 103
 
104
-                if(!empty($this->config[ 'itemDetailedDate' ])){
104
+                if (!empty($this->config['itemDetailedDate'])) {
105 105
                     $set += [
106 106
                       self::DRIVER_MDATE_WRAPPER_INDEX => ($item->getModificationDate() ? new UTCDateTime(($item->getModificationDate()->getTimestamp()) * 1000) : new UTCDateTime(time() * 1000)),
107 107
                       self::DRIVER_CDATE_WRAPPER_INDEX => ($item->getCreationDate() ? new UTCDateTime(($item->getCreationDate()->getTimestamp()) * 1000) : new UTCDateTime(time() * 1000)),
108 108
                     ];
109 109
                 }
110 110
 
111
-                $result = (array)$this->getCollection()->updateOne(
111
+                $result = (array) $this->getCollection()->updateOne(
112 112
                   ['_id' => $item->getEncodedKey()],
113 113
                   ['$set' => $set],
114 114
                   ['upsert' => true, 'multiple' => false]
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
                 throw new phpFastCacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e);
118 118
             }
119 119
 
120
-            return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true;
120
+            return isset($result['ok']) ? $result['ok'] == 1 : true;
121 121
         } else {
122 122
             throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected');
123 123
         }
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
 
134 134
         if ($document) {
135 135
             $return = [
136
-              self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()),
137
-              self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()),
138
-              self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
136
+              self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->getData()),
137
+              self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->getData()),
138
+              self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_EDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()),
139 139
             ];
140 140
 
141
-            if(!empty($this->config[ 'itemDetailedDate' ])){
141
+            if (!empty($this->config['itemDetailedDate'])) {
142 142
                 $return += [
143
-                  self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_MDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
144
-                  self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_CDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
143
+                  self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_MDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()),
144
+                  self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_CDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()),
145 145
                 ];
146 146
             }
147 147
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
          */
190 190
         $this->save($this->getItem('__PFC_CACHE_CLEARED__')->set(true));
191 191
 
192
-        return !empty($result[ 'ok' ]);
192
+        return !empty($result['ok']);
193 193
     }
194 194
 
195 195
     /**
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
         if ($this->instance instanceof \MongoDB\Driver\Manager) {
203 203
             throw new LogicException('Already connected to Mongodb server');
204 204
         } else {
205
-            $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] * 1000 : 3000;
206
-            $collectionName = isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache';
207
-            $databaseName = isset($this->config[ 'databaseName' ]) ? $this->config[ 'databaseName' ] : 'phpFastCache';
205
+            $timeout = isset($this->config['timeout']) ? $this->config['timeout'] * 1000 : 3000;
206
+            $collectionName = isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache';
207
+            $databaseName = isset($this->config['databaseName']) ? $this->config['databaseName'] : 'phpFastCache';
208 208
 
209 209
             $this->instance = $this->instance ?: (new Client($this->buildConnectionURI(), ['connectTimeoutMS' => $timeout]));
210 210
             $this->database = $this->database ?: $this->instance->selectDatabase($databaseName);
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
      */
245 245
     protected function buildConnectionURI()
246 246
     {
247
-        $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1';
248
-        $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : '27017';
249
-        $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : '';
250
-        $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : '';
247
+        $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1';
248
+        $port = isset($this->config['port']) ? $this->config['port'] : '27017';
249
+        $password = isset($this->config['password']) ? $this->config['password'] : '';
250
+        $username = isset($this->config['username']) ? $this->config['username'] : '';
251 251
 
252 252
         $parts = [
253 253
             'mongodb://',
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
           'recordStats' => 0,
286 286
           'repl' => 0,
287 287
           'metrics' => 0,
288
-        ]))->toArray()[ 0 ];
288
+        ]))->toArray()[0];
289 289
 
290 290
         $collectionStats = $this->instance->getManager()->executeCommand('phpFastCache', new Command([
291
-          'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'),
291
+          'collStats' => (isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache'),
292 292
           'verbose' => true,
293
-        ]))->toArray()[ 0 ];
293
+        ]))->toArray()[0];
294 294
 
295
-        $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) {
295
+        $array_filter_recursive = function($array, callable $callback = null) use (&$array_filter_recursive) {
296 296
             $array = $callback($array);
297 297
 
298 298
             if (is_object($array) || is_array($array)) {
@@ -304,12 +304,12 @@  discard block
 block discarded – undo
304 304
             return $array;
305 305
         };
306 306
 
307
-        $callback = function ($item) {
307
+        $callback = function($item) {
308 308
             /**
309 309
              * Remove unserializable properties
310 310
              */
311 311
             if ($item instanceof \MongoDB\BSON\UTCDateTime) {
312
-                return (string)$item;
312
+                return (string) $item;
313 313
             }
314 314
             return $item;
315 315
         };
Please login to merge, or discard this patch.
src/phpFastCache/Entities/DriverStatistic.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     }
53 53
 
54 54
     /**
55
-     * @return int|bool Return size in octet or false if no information available
55
+     * @return string Return size in octet or false if no information available
56 56
      */
57 57
     public function getSize()
58 58
     {
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     }
61 61
 
62 62
     /**
63
-     * @return mixed
63
+     * @return string
64 64
      */
65 65
     public function getData()
66 66
     {
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     }
69 69
 
70 70
     /**
71
-     * @param $info
71
+     * @param string $info
72 72
      * @return $this
73 73
      */
74 74
     public function setInfo($info)
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -123,10 +123,10 @@
 block discarded – undo
123 123
     public function getPublicDesc()
124 124
     {
125 125
         return [
126
-          'Info' => 'Cache Information',
127
-          'Size' => 'Cache Size',
128
-          'Data' => 'Cache items keys',
129
-          'RawData' => 'Cache raw data',
126
+            'Info' => 'Cache Information',
127
+            'Size' => 'Cache Size',
128
+            'Data' => 'Cache items keys',
129
+            'RawData' => 'Cache raw data',
130 130
         ];
131 131
     }
132 132
 }
133 133
\ No newline at end of file
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Wincache/Driver.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -133,9 +133,9 @@
 block discarded – undo
133 133
         $date = (new \DateTime())->setTimestamp(time() - $info[ 'total_cache_uptime' ]);
134 134
 
135 135
         return (new DriverStatistic())
136
-          ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822)))
137
-          ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ])
138
-          ->setData(implode(', ', array_keys($this->itemInstances)))
139
-          ->setRawData($memInfo);
136
+            ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822)))
137
+            ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ])
138
+            ->setData(implode(', ', array_keys($this->itemInstances)))
139
+            ->setRawData($memInfo);
140 140
     }
141 141
 }
142 142
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,11 +130,11 @@
 block discarded – undo
130 130
     {
131 131
         $memInfo = wincache_ucache_meminfo();
132 132
         $info = wincache_ucache_info();
133
-        $date = (new \DateTime())->setTimestamp(time() - $info[ 'total_cache_uptime' ]);
133
+        $date = (new \DateTime())->setTimestamp(time() - $info['total_cache_uptime']);
134 134
 
135 135
         return (new DriverStatistic())
136 136
           ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822)))
137
-          ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ])
137
+          ->setSize($memInfo['memory_free'] - $memInfo['memory_total'])
138 138
           ->setData(implode(', ', array_keys($this->itemInstances)))
139 139
           ->setRawData($memInfo);
140 140
     }
Please login to merge, or discard this patch.