Completed
Pull Request — final (#326)
by
unknown
02:48
created
src/phpFastCache/Cache/DriverBaseTrait.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@
 block discarded – undo
115 115
 
116 116
 
117 117
     /**
118
-     * @param $file
118
+     * @param string $file
119 119
      * @return string
120 120
      * @throws \Exception
121 121
      */
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -214,9 +214,9 @@
 block discarded – undo
214 214
     public function driverPreWrap(ExtendedCacheItemInterface $item)
215 215
     {
216 216
         return [
217
-          self::DRIVER_DATA_WRAPPER_INDEX => $item->get(),
218
-          self::DRIVER_TIME_WRAPPER_INDEX => $item->getExpirationDate(),
219
-          self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(),
217
+            self::DRIVER_DATA_WRAPPER_INDEX => $item->get(),
218
+            self::DRIVER_TIME_WRAPPER_INDEX => $item->getExpirationDate(),
219
+            self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(),
220 220
         ];
221 221
     }
222 222
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         if (is_array($config_name)) {
61 61
             $this->config = array_merge($this->config, $config_name);
62 62
         } else {
63
-            $this->config[ $config_name ] = $value;
63
+            $this->config[$config_name] = $value;
64 64
         }
65 65
     }
66 66
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public function driverUnwrapData(array $wrapper)
181 181
     {
182
-        return $wrapper[ self::DRIVER_DATA_WRAPPER_INDEX ];
182
+        return $wrapper[self::DRIVER_DATA_WRAPPER_INDEX];
183 183
     }
184 184
 
185 185
     /**
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
      */
189 189
     public function driverUnwrapTags(array $wrapper)
190 190
     {
191
-        return $wrapper[ self::DRIVER_TAGS_WRAPPER_INDEX ];
191
+        return $wrapper[self::DRIVER_TAGS_WRAPPER_INDEX];
192 192
     }
193 193
 
194 194
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      */
199 199
     public function driverUnwrapTime(array $wrapper)
200 200
     {
201
-        return $wrapper[ self::DRIVER_TIME_WRAPPER_INDEX ];
201
+        return $wrapper[self::DRIVER_TIME_WRAPPER_INDEX];
202 202
     }
203 203
 
204 204
     /**
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
          * on tags item, it can leads
224 224
          * to an infinite recursive calls
225 225
          */
226
-        if(strpos($item->getKey(), self::DRIVER_TAGS_KEY_PREFIX ) === 0){
226
+        if (strpos($item->getKey(), self::DRIVER_TAGS_KEY_PREFIX) === 0) {
227 227
             throw new \LogicException('Trying to set tag(s) to an Tag item index: ' . $item->getKey());
228 228
         }
229 229
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
         foreach ($tagsItems as $tagsItem) {
267 267
             $data = (array) $tagsItem->get();
268 268
 
269
-            unset($data[ $item->getKey() ]);
269
+            unset($data[$item->getKey()]);
270 270
             $tagsItem->set($data);
271 271
 
272 272
             /**
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Files/Driver.php 4 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
     /**
57 57
      * @param \Psr\Cache\CacheItemInterface $item
58
-     * @return mixed
58
+     * @return boolean|null
59 59
      * @throws \InvalidArgumentException
60 60
      */
61 61
     public function driverWrite(CacheItemInterface $item)
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     /**
212 212
      * @param string $optionName
213 213
      * @param mixed $optionValue
214
-     * @return bool
214
+     * @return boolean|null
215 215
      * @throws \InvalidArgumentException
216 216
      */
217 217
     public static function isValidOption($optionName, $optionValue)
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
         }
240 240
     }
241 241
     /**
242
-     * @return array
242
+     * @return string[]
243 243
      */
244 244
     public static function getValidOptions()
245 245
     {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
     }
248 248
 
249 249
     /**
250
-     * @return array
250
+     * @return string[]
251 251
      */
252 252
     public static function getRequiredOptions()
253 253
     {
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -254,9 +254,9 @@
 block discarded – undo
254 254
         }
255 255
 
256 256
         $stat->setData(implode(', ', array_keys($this->itemInstances)))
257
-          ->setRawData([])
258
-          ->setSize(Directory::dirSize($path))
259
-          ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
257
+            ->setRawData([])
258
+            ->setSize(Directory::dirSize($path))
259
+            ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
260 260
 
261 261
         return $stat;
262 262
     }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
             /*
76 76
              * Skip if Existing Caching in Options
77 77
              */
78
-            if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true && file_exists($file_path)) {
78
+            if (isset($option['skipExisting']) && $option['skipExisting'] == true && file_exists($file_path)) {
79 79
                 $content = $this->readfile($file_path);
80 80
                 $old = $this->decode($content);
81 81
                 $toWrite = false;
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,6 @@
 block discarded – undo
15 15
 namespace phpFastCache\Drivers\Wincache;
16 16
 
17 17
 use phpFastCache\Core\DriverAbstract;
18
-use phpFastCache\Core\StandardPsr6StructureTrait;
19 18
 use phpFastCache\Entities\driverStatistic;
20 19
 use phpFastCache\Exceptions\phpFastCacheDriverCheckException;
21 20
 use phpFastCache\Exceptions\phpFastCacheDriverException;
Please login to merge, or discard this patch.
src/phpFastCache/Core/PathSeekerTrait.php 3 patches
Doc Comments   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,7 +25,6 @@  discard block
 block discarded – undo
25 25
     public $tmp = [];
26 26
 
27 27
     /**
28
-     * @param bool $skip_create_path
29 28
      * @param $config
30 29
      * @return string
31 30
      * @throws \Exception
@@ -118,7 +117,7 @@  discard block
 block discarded – undo
118 117
     }
119 118
 
120 119
     /**
121
-     * @param $keyword
120
+     * @param string|false $keyword
122 121
      * @param bool $skip
123 122
      * @return string
124 123
      * @throws phpFastCacheDriverException
@@ -165,7 +164,7 @@  discard block
 block discarded – undo
165 164
 
166 165
     /**
167 166
      * @param $filename
168
-     * @return mixed
167
+     * @return string
169 168
      */
170 169
     protected static function cleanFileName($filename)
171 170
     {
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
     }
181 180
 
182 181
     /**
183
-     * @param $path
182
+     * @param string $path
184 183
      * @param bool $create
185 184
      * @throws \Exception
186 185
      */
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -185,9 +185,9 @@
 block discarded – undo
185 185
     protected static function cleanFileName($filename)
186 186
     {
187 187
         $regex = [
188
-          '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/',
189
-          '/\.$/',
190
-          '/^\./',
188
+            '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/',
189
+            '/\.$/',
190
+            '/^\./',
191 191
         ];
192 192
         $replace = ['-', '', ''];
193 193
 
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -34,30 +34,30 @@  discard block
 block discarded – undo
34 34
     {
35 35
         $tmp_dir = rtrim(ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(), '\\/') . DIRECTORY_SEPARATOR . 'phpfastcache';
36 36
 
37
-        if (!isset($this->config[ 'path' ]) || $this->config[ 'path' ] == '') {
37
+        if (!isset($this->config['path']) || $this->config['path'] == '') {
38 38
             if (self::isPHPModule()) {
39 39
                 $path = $tmp_dir;
40 40
             } else {
41
-                $document_root_path = rtrim($_SERVER[ 'DOCUMENT_ROOT' ], '/') . '/../';
42
-                $path = isset($_SERVER[ 'DOCUMENT_ROOT' ]) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . '/';
41
+                $document_root_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/../';
42
+                $path = isset($_SERVER['DOCUMENT_ROOT']) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . '/';
43 43
             }
44 44
 
45
-            if ($this->config[ 'path' ] != '') {
46
-                $path = $this->config[ 'path' ];
45
+            if ($this->config['path'] != '') {
46
+                $path = $this->config['path'];
47 47
             }
48 48
 
49 49
         } else {
50
-            $path = $this->config[ 'path' ];
50
+            $path = $this->config['path'];
51 51
         }
52 52
 
53 53
         if ($getBasePath === true) {
54 54
             return $path;
55 55
         }
56 56
 
57
-        $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : '';
57
+        $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : '';
58 58
         if (!$securityKey || $securityKey === 'auto') {
59
-            if (isset($_SERVER[ 'HTTP_HOST' ])) {
60
-                $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ])));
59
+            if (isset($_SERVER['HTTP_HOST'])) {
60
+                $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST'])));
61 61
             } else {
62 62
                 $securityKey = ($this->isPHPModule() ? 'web' : 'cli');
63 63
             }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         $full_pathx = md5($full_path);
74 74
 
75 75
 
76
-        if (!isset($this->tmp[ $full_pathx ])) {
76
+        if (!isset($this->tmp[$full_pathx])) {
77 77
 
78 78
             if (!@file_exists($full_path) || !@is_writable($full_path)) {
79 79
                 if (!@file_exists($full_path)) {
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
                 }
98 98
             }
99 99
 
100
-            $this->tmp[ $full_pathx ] = true;
101
-            $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false);
100
+            $this->tmp[$full_pathx] = true;
101
+            $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false);
102 102
         }
103 103
 
104 104
         return realpath($full_path);
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public function setChmodAuto()
173 173
     {
174
-        if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) {
174
+        if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) {
175 175
             return 0777;
176 176
         } else {
177
-            return $this->config[ 'default_chmod' ];
177
+            return $this->config['default_chmod'];
178 178
         }
179 179
     }
180 180
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         if ($create === true) {
205 205
             if (!is_writable($path)) {
206 206
                 try {
207
-                    if(!chmod($path, 0777)){
207
+                    if (!chmod($path, 0777)) {
208 208
                         throw new phpFastCacheDriverException('Chmod failed on : ' . $path);
209 209
                     }
210 210
                 } catch (phpFastCacheDriverException $e) {
Please login to merge, or discard this patch.
src/phpFastCache/Util/Directory.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@
 block discarded – undo
83 83
 
84 84
         $files = new RecursiveIteratorIterator
85 85
         (
86
-          new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
87
-          RecursiveIteratorIterator::CHILD_FIRST
86
+            new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
87
+            RecursiveIteratorIterator::CHILD_FIRST
88 88
         );
89 89
         
90 90
         foreach ($files as $fileinfo) {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
             return unlink($source);
82 82
         }
83 83
 
84
-        $files = new RecursiveIteratorIterator
85
-        (
84
+        $files = new RecursiveIteratorIterator(
86 85
           new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
87 86
           RecursiveIteratorIterator::CHILD_FIRST
88 87
         );
@@ -95,7 +94,7 @@  discard block
 block discarded – undo
95 94
                 if (self::rrmdir($fileinfo->getRealPath()) === false) {
96 95
                     return false;
97 96
                 }
98
-            } else if(unlink($fileinfo->getRealPath()) === false) {
97
+            } else if (unlink($fileinfo->getRealPath()) === false) {
99 98
                 return false;
100 99
             }
101 100
         }
Please login to merge, or discard this patch.
src/phpFastCache/Entities/driverStatistic.php 1 patch
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     protected $rawData;
45 45
 
46 46
     /**
47
-     * @return string|bool Return infos or false if no information available
47
+     * @return string Return infos or false if no information available
48 48
      */
49 49
     public function getInfo()
50 50
     {
@@ -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.
src/phpFastCache/Drivers/Devfalse/Driver.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -140,9 +140,9 @@
 block discarded – undo
140 140
     {
141 141
         $stat = new driverStatistic();
142 142
         $stat->setInfo('[Devfalse] A void info string')
143
-          ->setSize(0)
144
-          ->setData(implode(', ', array_keys($this->itemInstances)))
145
-          ->setRawData(false);
143
+            ->setSize(0)
144
+            ->setData(implode(', ', array_keys($this->itemInstances)))
145
+            ->setRawData(false);
146 146
 
147 147
         return $stat;
148 148
     }
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Devnull/Driver.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -140,9 +140,9 @@
 block discarded – undo
140 140
     {
141 141
         $stat = new driverStatistic();
142 142
         $stat->setInfo('[Devnull] A void info string')
143
-          ->setSize(0)
144
-          ->setData(implode(', ', array_keys($this->itemInstances)))
145
-          ->setRawData(null);
143
+            ->setSize(0)
144
+            ->setData(implode(', ', array_keys($this->itemInstances)))
145
+            ->setRawData(null);
146 146
 
147 147
         return $stat;
148 148
     }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
 
58 58
     /**
59 59
      * @param \Psr\Cache\CacheItemInterface $item
60
-     * @return mixed
60
+     * @return boolean
61 61
      * @throws \InvalidArgumentException
62 62
      */
63 63
     public function driverWrite(CacheItemInterface $item)
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,6 @@
 block discarded – undo
15 15
 namespace phpFastCache\Drivers\Wincache;
16 16
 
17 17
 use phpFastCache\Core\DriverAbstract;
18
-use phpFastCache\Core\StandardPsr6StructureTrait;
19 18
 use phpFastCache\Entities\driverStatistic;
20 19
 use phpFastCache\Exceptions\phpFastCacheDriverCheckException;
21 20
 use phpFastCache\Exceptions\phpFastCacheDriverException;
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Mongodb/Driver.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
     /**
55 55
      * @param \Psr\Cache\CacheItemInterface $item
56
-     * @return mixed
56
+     * @return boolean
57 57
      * @throws \InvalidArgumentException
58 58
      */
59 59
     public function driverWrite(CacheItemInterface $item)
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
     /**
114 114
      * @param \Psr\Cache\CacheItemInterface $item
115
-     * @return bool
115
+     * @return boolean|null
116 116
      * @throws \InvalidArgumentException
117 117
      */
118 118
     public function driverIsHit(CacheItemInterface $item)
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             For MongoDb with Mongo PECL support use Mongo Driver.', E_USER_ERROR);
68 68
         }
69 69
         
70
-      /*  if(!class_exists('MongoDB\Driver\Collection')){
70
+        /*  if(!class_exists('MongoDB\Driver\Collection')){
71 71
         	trigger_error('The library mongo-php-library not found.<br />
72 72
             This driver do not support MonboDb low-level driver alone. Please install this driver to continue: https://github.com/mongodb/mongo-php-library', E_USER_ERROR);
73 73
         } */
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
         if ($item instanceof Item) {
89 89
             try {
90 90
                 $result = (array) $this->getCollection()->updateMany(
91
-                  ['_id' => $item->getKey()],
92
-                  [
91
+                    ['_id' => $item->getKey()],
92
+                    [
93 93
                     '$set' => [
94
-                      self::DRIVER_TIME_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time()*1000)),
95
-                      self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC),
96
-                      self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC),
94
+                        self::DRIVER_TIME_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time()*1000)),
95
+                        self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC),
96
+                        self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC),
97 97
                     ],
98
-                  ],
99
-                  ['upsert' => true, 'multiple' => false]
98
+                    ],
99
+                    ['upsert' => true, 'multiple' => false]
100 100
                 );
101 101
             } catch (MongoCursorException $e) {
102 102
                 return false;
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
     protected function driverRead(CacheItemInterface $item)
116 116
     {
117 117
         $document = $this->getCollection()
118
-          ->findOne(['_id' => $item->getKey()],
118
+            ->findOne(['_id' => $item->getKey()],
119 119
             [self::DRIVER_DATA_WRAPPER_INDEX, self::DRIVER_TIME_WRAPPER_INDEX, self::DRIVER_TAGS_WRAPPER_INDEX  /*'d', 'e'*/]);
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;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
          */
142 142
         if ($item instanceof Item) {
143 143
             $deletionResult = (array) $this->getCollection()->deleteMany(['_id' => $item->getKey()], ["w" => 1]);
144
-			// new driver has no results for deleteMany or deleteOne
144
+            // new driver has no results for deleteMany or deleteOne
145 145
             return true;
146 146
         } else {
147 147
             throw new \InvalidArgumentException('Cross-Driver type confusion detected');
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
              * @todo make an url builder
178 178
              */
179 179
             $this->instance = $this->instance ?: (new \MongoDB\Driver\Manager('mongodb://' .
180
-              ($username ?: '') .
181
-              ($password ? ":{$password}" : '') .
182
-              ($username ? '@' : '') . "{$host}" .
183
-              ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]));
184
-              $this->collection = $this->collection ?: new Collection($this->instance,'phpFastCache','Cache'); 
185
-         }
180
+                ($username ?: '') .
181
+                ($password ? ":{$password}" : '') .
182
+                ($username ? '@' : '') . "{$host}" .
183
+                ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]));
184
+                $this->collection = $this->collection ?: new Collection($this->instance,'phpFastCache','Cache'); 
185
+            }
186 186
     }
187 187
 
188 188
 
@@ -206,25 +206,25 @@  discard block
 block discarded – undo
206 206
     public function getStats()
207 207
     {
208 208
         $serverStatus = $this->instance->executeCommand(new Command([
209
-          'serverStatus' => 1,
210
-          'recordStats' => 0,
211
-          'repl' => 0,
212
-          'metrics' => 0,
209
+            'serverStatus' => 1,
210
+            'recordStats' => 0,
211
+            'repl' => 0,
212
+            'metrics' => 0,
213 213
         ]));
214 214
 
215 215
         $collStats = $this->instance->executeCommand(new Command([
216
-          'collStats' => 'Cache',
217
-          'verbose' => true,
216
+            'collStats' => 'Cache',
217
+            'verbose' => true,
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' ])
223
-          ->setData(implode(', ', array_keys($this->itemInstances)))
224
-          ->setRawData([
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
+            ->setData(implode(', ', array_keys($this->itemInstances)))
224
+            ->setRawData([
225 225
             'serverStatus' => $serverStatus,
226 226
             'collStats' => $collStats,
227
-          ]);
227
+            ]);
228 228
 
229 229
         return $stats;
230 230
     }
Please login to merge, or discard this 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.
tests/Psr6InterfaceImplements.test.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@
 block discarded – undo
23 23
 if (!is_object($driverInstance)) {
24 24
     echo '[FAIL] CacheManager::getInstance() returned an invalid variable type:' . gettype($driverInstance) . "\n";
25 25
     $status = 1;
26
-}else if(!($driverInstance instanceof CacheItemPoolInterface)){
26
+} else if (!($driverInstance instanceof CacheItemPoolInterface)) {
27 27
     echo '[FAIL] CacheManager::getInstance() returned an invalid class:' . get_class($driverInstance) . "\n";
28 28
     $status = 1;
29
-}else{
29
+} else {
30 30
     echo '[PASS] CacheManager::getInstance() returned a valid CacheItemPoolInterface object: ' . get_class($driverInstance) . "\n";
31 31
 }
32 32
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@
 block discarded – undo
23 23
 if (!is_object($driverInstance)) {
24 24
     echo '[FAIL] CacheManager::getInstance() returned an invalid variable type:' . gettype($driverInstance) . "\n";
25 25
     $status = 1;
26
-}else if(!($driverInstance instanceof CacheItemPoolInterface)){
26
+} else if(!($driverInstance instanceof CacheItemPoolInterface)){
27 27
     echo '[FAIL] CacheManager::getInstance() returned an invalid class:' . get_class($driverInstance) . "\n";
28 28
     $status = 1;
29
-}else{
29
+} else{
30 30
     echo '[PASS] CacheManager::getInstance() returned a valid CacheItemPoolInterface object: ' . get_class($driverInstance) . "\n";
31 31
 }
32 32
 
Please login to merge, or discard this patch.