Passed
Push — v7 ( 338244...de4ac6 )
by Georges
01:40
created
lib/Phpfastcache/Drivers/Couchdb/Driver.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
 namespace Phpfastcache\Drivers\Couchdb;
17 17
 
18 18
 use Doctrine\CouchDB\{
19
-  CouchDBClient as CouchdbClient, CouchDBException
19
+    CouchDBClient as CouchdbClient, CouchDBException
20 20
 };
21 21
 use Phpfastcache\Config\ConfigurationOption;
22 22
 use Phpfastcache\Core\Pool\{
23
-  DriverBaseTrait, ExtendedCacheItemPoolInterface
23
+    DriverBaseTrait, ExtendedCacheItemPoolInterface
24 24
 };
25 25
 use Phpfastcache\Exceptions\{
26
-  PhpfastcacheDriverException, PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException
26
+    PhpfastcacheDriverException, PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException
27 27
 };
28 28
 use Phpfastcache\Entities\DriverStatistic;
29 29
 use Phpfastcache\Util\ArrayObject;
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
         $url .= $clientConfig->getPath();
76 76
 
77 77
         $this->instance = CouchDBClient::create([
78
-          'dbname' => $this->getDatabaseName(),
79
-          'url' => $url,
80
-          'timeout' => $clientConfig->getTimeout(),
78
+            'dbname' => $this->getDatabaseName(),
79
+            'url' => $url,
80
+            'timeout' => $clientConfig->getTimeout(),
81 81
         ]);
82 82
 
83 83
         $this->createDatabase();
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         if ($item instanceof Item) {
125 125
             try {
126 126
                 $this->instance->putDocument(['data' => $this->encode($this->driverPreWrap($item))], $item->getEncodedKey(),
127
-                  $this->getLatestDocumentRevision($item->getEncodedKey()));
127
+                    $this->getLatestDocumentRevision($item->getEncodedKey()));
128 128
             } catch (CouchDBException $e) {
129 129
                 throw new PhpfastcacheDriverException('Got error while trying to upsert a document: ' . $e->getMessage(), null, $e);
130 130
             }
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
         $path = '/' . $this->getDatabaseName() . '/' . urlencode($docId);
182 182
 
183 183
         $response = $this->instance->getHttpClient()->request(
184
-          'HEAD',
185
-          $path,
186
-          null,
187
-          false
184
+            'HEAD',
185
+            $path,
186
+            null,
187
+            false
188 188
         );
189 189
         if (!empty($response->headers[ 'etag' ])) {
190 190
             return \trim($response->headers[ 'etag' ], " '\"\t\n\r\0\x0B");
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
         $info = $this->instance->getDatabaseInfo();
239 239
 
240 240
         return (new DriverStatistic())
241
-          ->setSize($info[ 'sizes' ][ 'active' ])
242
-          ->setRawData($info)
243
-          ->setData(\implode(', ', \array_keys($this->itemInstances)))
244
-          ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData.");
241
+            ->setSize($info[ 'sizes' ][ 'active' ])
242
+            ->setRawData($info)
243
+            ->setData(\implode(', ', \array_keys($this->itemInstances)))
244
+            ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData.");
245 245
     }
246 246
 }
247 247
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @author Georges.L (Geolim4)  <[email protected]>
12 12
  *
13 13
  */
14
-declare(strict_types=1);
14
+declare(strict_types = 1);
15 15
 
16 16
 namespace Phpfastcache\Drivers\Couchdb;
17 17
 
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
             throw new PhpfastcacheDriverException('Got error while trying to get a document: ' . $e->getMessage(), null, $e);
99 99
         }
100 100
 
101
-        if ($response->status === 404 || empty($response->body[ 'data' ])) {
101
+        if ($response->status === 404 || empty($response->body['data'])) {
102 102
             return null;
103 103
         }
104 104
 
105 105
         if ($response->status === 200) {
106
-            return $this->decode($response->body[ 'data' ]);
106
+            return $this->decode($response->body['data']);
107 107
         }
108 108
 
109 109
         throw new PhpfastcacheDriverException('Got unexpected HTTP status: ' . $response->status);
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
           null,
187 187
           false
188 188
         );
189
-        if (!empty($response->headers[ 'etag' ])) {
190
-            return \trim($response->headers[ 'etag' ], " '\"\t\n\r\0\x0B");
189
+        if (!empty($response->headers['etag'])) {
190
+            return \trim($response->headers['etag'], " '\"\t\n\r\0\x0B");
191 191
         }
192 192
 
193 193
         return null;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
         $info = $this->instance->getDatabaseInfo();
239 239
 
240 240
         return (new DriverStatistic())
241
-          ->setSize($info[ 'sizes' ][ 'active' ])
241
+          ->setSize($info['sizes']['active'])
242 242
           ->setRawData($info)
243 243
           ->setData(\implode(', ', \array_keys($this->itemInstances)))
244 244
           ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData.");
Please login to merge, or discard this patch.
lib/Phpfastcache/CacheManager.php 3 patches
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
               'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead',
118 118
               E_USER_DEPRECATED
119 119
             );
120
-        }elseif ($config === null){
120
+        } elseif ($config === null){
121 121
             $config = self::getDefaultConfig();
122
-        }else if(!($config instanceof ConfigurationOption)){
122
+        } else if(!($config instanceof ConfigurationOption)){
123 123
             throw new PhpfastcacheInvalidArgumentException(\sprintf('Unsupported config type: %s', gettype($config)));
124 124
         }
125 125
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
     {
405 405
         if(!empty(self::$driverCustoms[$driverName])){
406 406
             $driverClass = self::$driverCustoms[$driverName];
407
-        }else if(!empty(self::$driverOverrides[$driverName])){
407
+        } else if(!empty(self::$driverOverrides[$driverName])){
408 408
             $driverClass = self::$driverOverrides[$driverName];
409 409
         } else{
410 410
             $driverClass = self::getNamespacePath() . $driverName . '\Driver';
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 use Phpfastcache\Config\ConfigurationOption;
19 19
 use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface;
20 20
 use Phpfastcache\Exceptions\{
21
-  PhpfastcacheDeprecatedException, PhpfastcacheDriverCheckException, PhpfastcacheDriverException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException, PhpfastcacheLogicException, PhpfastcacheUnsupportedOperationException
21
+    PhpfastcacheDeprecatedException, PhpfastcacheDriverCheckException, PhpfastcacheDriverException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException, PhpfastcacheLogicException, PhpfastcacheUnsupportedOperationException
22 22
 };
23 23
 use Phpfastcache\Util\ClassNamespaceResolverTrait;
24 24
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
         if (\is_array($config)) {
116 116
             $config = new ConfigurationOption($config);
117 117
             trigger_error(
118
-              'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead',
119
-              E_USER_DEPRECATED
118
+                'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead',
119
+                E_USER_DEPRECATED
120 120
             );
121 121
         }elseif ($config === null){
122 122
             $config = self::getDefaultConfig();
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 
139 139
             if(!is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)){
140 140
                 throw new PhpfastcacheDriverException(sprintf(
141
-                  'Class "%s" does not implement "%s"',
142
-                  $driverClass,
143
-                  ExtendedCacheItemPoolInterface::class
141
+                    'Class "%s" does not implement "%s"',
142
+                    $driverClass,
143
+                    ExtendedCacheItemPoolInterface::class
144 144
                 ));
145 145
             }
146 146
             try {
@@ -327,27 +327,27 @@  discard block
 block discarded – undo
327 327
     {
328 328
         trigger_error(\sprintf('Method "%s" is deprecated as of the V7 and will be removed soon or later, use CacheManager::getDriverList() instead.', __METHOD__), E_USER_DEPRECATED);
329 329
         return [
330
-          'Apc',
331
-          'Apcu',
332
-          'Cassandra',
333
-          'Couchbase',
334
-          'Couchdb',
335
-          'Devnull',
336
-          'Files',
337
-          'Leveldb',
338
-          'Memcache',
339
-          'Memcached',
340
-          'Memstatic',
341
-          'Mongodb',
342
-          'Predis',
343
-          'Redis',
344
-          'Riak',
345
-          'Ssdb',
346
-          'Sqlite',
347
-          'Wincache',
348
-          'Xcache',
349
-          'Zenddisk',
350
-          'Zendshm',
330
+            'Apc',
331
+            'Apcu',
332
+            'Cassandra',
333
+            'Couchbase',
334
+            'Couchdb',
335
+            'Devnull',
336
+            'Files',
337
+            'Leveldb',
338
+            'Memcache',
339
+            'Memcached',
340
+            'Memstatic',
341
+            'Mongodb',
342
+            'Predis',
343
+            'Redis',
344
+            'Riak',
345
+            'Ssdb',
346
+            'Sqlite',
347
+            'Wincache',
348
+            'Xcache',
349
+            'Zenddisk',
350
+            'Zendshm',
351 351
         ];
352 352
     }
353 353
 
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
     {
360 360
         trigger_error(\sprintf('Method "%s" is deprecated as of the V7 and will be removed soon or later, use CacheManager::getDriverList() instead.', __METHOD__), E_USER_DEPRECATED);
361 361
         return \array_merge(self::getStaticSystemDrivers(), [
362
-          'Devtrue',
363
-          'Devfalse',
364
-          'Cookie',
362
+            'Devtrue',
363
+            'Devfalse',
364
+            'Cookie',
365 365
         ]);
366 366
     }
367 367
 
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 
440 440
         if(!\class_exists($className)){
441 441
             throw new PhpfastcacheInvalidArgumentException(
442
-              sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className)
442
+                sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className)
443 443
             );
444 444
         }
445 445
 
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 
493 493
         if(!\class_exists($className)){
494 494
             throw new PhpfastcacheInvalidArgumentException(
495
-              sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className)
495
+                sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className)
496 496
             );
497 497
         }
498 498
 
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @author Georges.L (Geolim4)  <[email protected]>
12 12
  *
13 13
  */
14
-declare(strict_types=1);
14
+declare(strict_types = 1);
15 15
 
16 16
 namespace Phpfastcache;
17 17
 
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
               'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead',
119 119
               E_USER_DEPRECATED
120 120
             );
121
-        }elseif ($config === null){
121
+        }elseif ($config === null) {
122 122
             $config = self::getDefaultConfig();
123
-        }else if(!($config instanceof ConfigurationOption)){
123
+        } else if (!($config instanceof ConfigurationOption)) {
124 124
             throw new PhpfastcacheInvalidArgumentException(\sprintf('Unsupported config type: %s', gettype($config)));
125 125
         }
126 126
 
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 
133 133
         $instance = $instanceId ?: md5($driver . \serialize($config->toArray()));
134 134
 
135
-        if (!isset(self::$instances[ $instance ])) {
136
-            $badPracticeOmeter[ $driver ] = 1;
135
+        if (!isset(self::$instances[$instance])) {
136
+            $badPracticeOmeter[$driver] = 1;
137 137
             $driverClass = self::getDriverClass($driver);
138 138
 
139
-            if(!is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)){
139
+            if (!is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)) {
140 140
                 throw new PhpfastcacheDriverException(sprintf(
141 141
                   'Class "%s" does not implement "%s"',
142 142
                   $driverClass,
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
             try {
147 147
                 if (\class_exists($driverClass)) {
148 148
                     $configClass = $driverClass::getConfigClass();
149
-                    self::$instances[ $instance ] = new $driverClass(new $configClass($config->toArray()), $instance);
150
-                    self::$instances[ $instance ]->setEventManager(EventManager::getInstance());
149
+                    self::$instances[$instance] = new $driverClass(new $configClass($config->toArray()), $instance);
150
+                    self::$instances[$instance]->setEventManager(EventManager::getInstance());
151 151
                 } else {
152 152
                     throw new PhpfastcacheDriverNotFoundException(\sprintf('The driver "%s" does not exists', $driver));
153 153
                 }
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
                     throw new PhpfastcacheDriverCheckException($e->getMessage(), $e->getCode(), $e);
166 166
                 }
167 167
             }
168
-        } else if ($badPracticeOmeter[ $driver ] >= 2) {
168
+        } else if ($badPracticeOmeter[$driver] >= 2) {
169 169
             trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances.
170 170
            See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F');
171 171
         }
172 172
 
173
-        $badPracticeOmeter[ $driver ]++;
173
+        $badPracticeOmeter[$driver]++;
174 174
 
175
-        return self::$instances[ $instance ];
175
+        return self::$instances[$instance];
176 176
     }
177 177
 
178 178
     /**
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
             throw new PhpfastcacheInvalidArgumentException('The Instance ID must be a string');
190 190
         }
191 191
 
192
-        if (isset(self::$instances[ $instanceId ])) {
193
-            return self::$instances[ $instanceId ];
192
+        if (isset(self::$instances[$instanceId])) {
193
+            return self::$instances[$instanceId];
194 194
         }
195 195
 
196 196
         throw new PhpfastcacheInstanceNotFoundException(\sprintf('Instance ID %s not found', $instanceId));
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
             }
248 248
         }
249 249
 
250
-        if(!$autoDriver || !\is_string($autoDriver)){
250
+        if (!$autoDriver || !\is_string($autoDriver)) {
251 251
             throw new PhpfastcacheLogicException('Unable to find out a valid driver automatically');
252 252
         }
253 253
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
      */
262 262
     public static function __callStatic(string $name, array $arguments): ExtendedCacheItemPoolInterface
263 263
     {
264
-        $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[ 0 ] : []);
264
+        $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[0] : []);
265 265
 
266 266
         return self::getInstance($name, $options);
267 267
     }
@@ -373,14 +373,14 @@  discard block
 block discarded – undo
373 373
     {
374 374
         static $driverList;
375 375
 
376
-        if(self::getDefaultNamespacePath() === self::getNamespacePath()){
377
-            if($driverList === null){
376
+        if (self::getDefaultNamespacePath() === self::getNamespacePath()) {
377
+            if ($driverList === null) {
378 378
                 $prefix = 'Phpfastcache\Drivers\\';
379 379
                 $classMap = self::createClassMap(__DIR__ . '/Drivers');
380 380
                 $driverList = [];
381 381
 
382 382
                 foreach ($classMap as $class => $file) {
383
-                    $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\') ));
383
+                    $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\')));
384 384
                 }
385 385
 
386 386
                 $driverList = array_values(array_unique($driverList));
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
      */
412 412
     public static function getDriverClass(string $driverName): string
413 413
     {
414
-        if(!empty(self::$driverCustoms[$driverName])){
414
+        if (!empty(self::$driverCustoms[$driverName])) {
415 415
             $driverClass = self::$driverCustoms[$driverName];
416
-        }else if(!empty(self::$driverOverrides[$driverName])){
416
+        } else if (!empty(self::$driverOverrides[$driverName])) {
417 417
             $driverClass = self::$driverOverrides[$driverName];
418
-        } else{
418
+        } else {
419 419
             $driverClass = self::getNamespacePath() . $driverName . '\Driver';
420 420
         }
421 421
 
@@ -430,24 +430,24 @@  discard block
 block discarded – undo
430 430
      * @throws \Phpfastcache\Exceptions\PhpfastcacheUnsupportedOperationException
431 431
      * @return void
432 432
      */
433
-    public static function addCustomDriver(string $driverName, string $className){
433
+    public static function addCustomDriver(string $driverName, string $className) {
434 434
         $driverName = self::standardizeDriverName($driverName);
435 435
 
436
-        if(empty($driverName)){
436
+        if (empty($driverName)) {
437 437
             throw new PhpfastcacheInvalidArgumentException("Can't add a custom driver because its name is empty");
438 438
         }
439 439
 
440
-        if(!\class_exists($className)){
440
+        if (!\class_exists($className)) {
441 441
             throw new PhpfastcacheInvalidArgumentException(
442 442
               sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className)
443 443
             );
444 444
         }
445 445
 
446
-        if(!empty(self::$driverCustoms[$driverName])){
446
+        if (!empty(self::$driverCustoms[$driverName])) {
447 447
             throw new PhpfastcacheLogicException(sprintf("Driver '%s' has been already added", $driverName));
448 448
         }
449 449
 
450
-        if(\in_array($driverName, self::getDriverList(), true)){
450
+        if (\in_array($driverName, self::getDriverList(), true)) {
451 451
             throw new PhpfastcacheLogicException(sprintf("Driver '%s' is already a part of the PhpFastCache core", $driverName));
452 452
         }
453 453
 
@@ -464,11 +464,11 @@  discard block
 block discarded – undo
464 464
     {
465 465
         $driverName = self::standardizeDriverName($driverName);
466 466
 
467
-        if(empty($driverName)){
467
+        if (empty($driverName)) {
468 468
             throw new PhpfastcacheInvalidArgumentException("Can't remove a custom driver because its name is empty");
469 469
         }
470 470
 
471
-        if(!isset(self::$driverCustoms[$driverName])){
471
+        if (!isset(self::$driverCustoms[$driverName])) {
472 472
             throw new PhpfastcacheLogicException(sprintf("Driver '%s' does not exists", $driverName));
473 473
         }
474 474
 
@@ -483,24 +483,24 @@  discard block
 block discarded – undo
483 483
      * @throws \Phpfastcache\Exceptions\PhpfastcacheUnsupportedOperationException
484 484
      * @return void
485 485
      */
486
-    public static function addCoreDriverOverride(string $driverName, string $className){
486
+    public static function addCoreDriverOverride(string $driverName, string $className) {
487 487
         $driverName = self::standardizeDriverName($driverName);
488 488
 
489
-        if(empty($driverName)){
489
+        if (empty($driverName)) {
490 490
             throw new PhpfastcacheInvalidArgumentException("Can't add a core driver override because its name is empty");
491 491
         }
492 492
 
493
-        if(!\class_exists($className)){
493
+        if (!\class_exists($className)) {
494 494
             throw new PhpfastcacheInvalidArgumentException(
495 495
               sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className)
496 496
             );
497 497
         }
498 498
 
499
-        if(!empty(self::$driverOverrides[$driverName])){
499
+        if (!empty(self::$driverOverrides[$driverName])) {
500 500
             throw new PhpfastcacheLogicException(sprintf("Driver '%s' has been already overridden", $driverName));
501 501
         }
502 502
 
503
-        if(!\in_array($driverName, self::getDriverList(), true)){
503
+        if (!\in_array($driverName, self::getDriverList(), true)) {
504 504
             throw new PhpfastcacheLogicException(sprintf("Driver '%s' can't be overridden since its not a part of the PhpFastCache core", $driverName));
505 505
         }
506 506
 
@@ -517,11 +517,11 @@  discard block
 block discarded – undo
517 517
     {
518 518
         $driverName = self::standardizeDriverName($driverName);
519 519
 
520
-        if(empty($driverName)){
520
+        if (empty($driverName)) {
521 521
             throw new PhpfastcacheInvalidArgumentException("Can't remove a core driver override because its name is empty");
522 522
         }
523 523
 
524
-        if(!isset(self::$driverOverrides[$driverName])){
524
+        if (!isset(self::$driverOverrides[$driverName])) {
525 525
             throw new PhpfastcacheLogicException(sprintf("Driver '%s' were not overridden", $driverName));
526 526
         }
527 527
 
Please login to merge, or discard this patch.