Passed
Push — master ( a3681d...4db184 )
by f
14:10
created
src/Drivers/NelexaZip.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,8 +42,9 @@
 block discarded – undo
42 42
         $information = new ArchiveInformation();
43 43
 
44 44
         foreach ($this->zip->getAllInfo() as $info) {
45
-            if ($info->isFolder())
46
-                continue;
45
+            if ($info->isFolder()) {
46
+                            continue;
47
+            }
47 48
 
48 49
             $this->files[] = $information->files[] = str_replace('\\', '/', $info->getName());
49 50
             $information->compressedFilesSize += $info->getCompressedSize();
Please login to merge, or discard this patch.
src/UnifiedArchive.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public static function open($fileName, $password = null, $abilities = [])
64 64
     {
65 65
         if (!file_exists($fileName) || !is_readable($fileName)) {
66
-            throw new InvalidArgumentException('Could not open file: ' . $fileName.' is not readable');
66
+            throw new InvalidArgumentException('Could not open file: '.$fileName.' is not readable');
67 67
         }
68 68
 
69 69
         $format = Formats::detectArchiveFormat($fileName);
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
     public function getFileData($fileName)
279 279
     {
280 280
         if (!in_array($fileName, $this->files, true)) {
281
-            throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive');
281
+            throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive');
282 282
         }
283 283
 
284 284
         return $this->archive->getFileData($fileName);
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
     public function getFileContent($fileName)
295 295
     {
296 296
         if (!in_array($fileName, $this->files, true)) {
297
-            throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive');
297
+            throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive');
298 298
         }
299 299
 
300 300
         return $this->archive->getFileContent($fileName);
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
     public function getFileStream($fileName)
311 311
     {
312 312
         if (!in_array($fileName, $this->files, true)) {
313
-            throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive');
313
+            throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive');
314 314
         }
315 315
 
316 316
         return $this->archive->getFileStream($fileName);
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
         /** @var BasicDriver $driver */
574 574
         $driver = Formats::getFormatDriver($info['type'], $abilities);
575 575
         if ($driver === null) {
576
-            throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ');
576
+            throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive ');
577 577
         }
578 578
 
579 579
         return $driver::createArchive(
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
     public static function archiveFile($file, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)
601 601
     {
602 602
         if (!is_file($file)) {
603
-            throw new InvalidArgumentException($file . ' is not a valid file to archive');
603
+            throw new InvalidArgumentException($file.' is not a valid file to archive');
604 604
         }
605 605
 
606 606
         return static::archiveFiles($file, $archiveName, $compressionLevel, $password) === 1;
@@ -671,8 +671,8 @@  discard block
 block discarded – undo
671 671
                 if (is_array($source)) {
672 672
                     foreach ($source as $sourceItem) {
673 673
                         static::importFilesFromDir(
674
-                            rtrim($sourceItem, '/\\*') . '/*',
675
-                            !empty($destination) ? $destination . '/' : null,
674
+                            rtrim($sourceItem, '/\\*').'/*',
675
+                            !empty($destination) ? $destination.'/' : null,
676 676
                             true,
677 677
                             $files
678 678
                         );
@@ -680,8 +680,8 @@  discard block
 block discarded – undo
680 680
                 } else if (is_dir($source)) {
681 681
                     // one source for directories
682 682
                     static::importFilesFromDir(
683
-                        rtrim($source, '/\\*') . '/*',
684
-                        !empty($destination) ? $destination . '/' : null,
683
+                        rtrim($source, '/\\*').'/*',
684
+                        !empty($destination) ? $destination.'/' : null,
685 685
                         true,
686 686
                         $files
687 687
                     );
Please login to merge, or discard this patch.
Braces   +44 added lines, -31 removed lines patch added patch discarded remove patch
@@ -257,13 +257,15 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public function getFileNames($filter = null)
259 259
     {
260
-        if ($filter === null)
261
-            return $this->files;
260
+        if ($filter === null) {
261
+                    return $this->files;
262
+        }
262 263
 
263 264
         $result = [];
264 265
         foreach ($this->files as $file) {
265
-            if (fnmatch($filter, $file))
266
-                $result[] = $file;
266
+            if (fnmatch($filter, $file)) {
267
+                            $result[] = $file;
268
+            }
267 269
         }
268 270
         return $result;
269 271
     }
@@ -390,8 +392,9 @@  discard block
 block discarded – undo
390 392
     {
391 393
         $files_list = static::createFilesList($fileOrFiles);
392 394
 
393
-        if (empty($files_list))
394
-            throw new EmptyFileListException('Files list is empty!');
395
+        if (empty($files_list)) {
396
+                    throw new EmptyFileListException('Files list is empty!');
397
+        }
395 398
 
396 399
         $result = $this->archive->addFiles($files_list);
397 400
         $this->scanArchive();
@@ -410,8 +413,9 @@  discard block
 block discarded – undo
410 413
      */
411 414
     public function addFile($file, $inArchiveName = null)
412 415
     {
413
-        if (!is_file($file))
414
-            throw new InvalidArgumentException($file.' is not a valid file to add in archive');
416
+        if (!is_file($file)) {
417
+                    throw new InvalidArgumentException($file.' is not a valid file to add in archive');
418
+        }
415 419
 
416 420
         return ($inArchiveName !== null
417 421
                 ? $this->addFiles([$inArchiveName => $file])
@@ -444,8 +448,9 @@  discard block
 block discarded – undo
444 448
      */
445 449
     public function addDirectory($directory, $inArchivePath = null)
446 450
     {
447
-        if (!is_dir($directory) || !is_readable($directory))
448
-            throw new InvalidArgumentException($directory.' is not a valid directory to add in archive');
451
+        if (!is_dir($directory) || !is_readable($directory)) {
452
+                    throw new InvalidArgumentException($directory.' is not a valid directory to add in archive');
453
+        }
449 454
 
450 455
         return ($inArchivePath !== null
451 456
                 ? $this->addFiles([$inArchivePath => $directory])
@@ -494,13 +499,15 @@  discard block
 block discarded – undo
494 499
     {
495 500
         $archiveType = Formats::detectArchiveFormat($archiveName, false);
496 501
 
497
-        if ($archiveType === false)
498
-            throw new UnsupportedArchiveException('Could not detect archive type for name "'.$archiveName.'"');
502
+        if ($archiveType === false) {
503
+                    throw new UnsupportedArchiveException('Could not detect archive type for name "'.$archiveName.'"');
504
+        }
499 505
 
500 506
         $files_list = static::createFilesList($fileOrFiles);
501 507
 
502
-        if (empty($files_list))
503
-            throw new EmptyFileListException('Files list is empty!');
508
+        if (empty($files_list)) {
509
+                    throw new EmptyFileListException('Files list is empty!');
510
+        }
504 511
 
505 512
         $totalSize = 0;
506 513
         foreach ($files_list as $fn) {
@@ -554,18 +561,21 @@  discard block
 block discarded – undo
554 561
         $fileProgressCallable = null
555 562
  )
556 563
     {
557
-        if (file_exists($archiveName))
558
-            throw new FileAlreadyExistsException('Archive '.$archiveName.' already exists!');
564
+        if (file_exists($archiveName)) {
565
+                    throw new FileAlreadyExistsException('Archive '.$archiveName.' already exists!');
566
+        }
559 567
 
560 568
         $info = static::prepareForArchiving($fileOrFiles, $archiveName);
561 569
 
562 570
         $abilities = [BasicDriver::CREATE];
563 571
 
564
-        if (!Formats::canCreate($info['type']))
565
-            throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '.$archiveName);
572
+        if (!Formats::canCreate($info['type'])) {
573
+                    throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '.$archiveName);
574
+        }
566 575
 
567
-        if ($password !== null && !Formats::canEncrypt($info['type']))
568
-            throw new UnsupportedOperationException('Archive type '.$info['type'].' can not be encrypted');
576
+        if ($password !== null && !Formats::canEncrypt($info['type'])) {
577
+                    throw new UnsupportedOperationException('Archive type '.$info['type'].' can not be encrypted');
578
+        }
569 579
         if ($password !== null) {
570 580
             $abilities[] = BasicDriver::CREATE_ENCRYPTED;
571 581
         }
@@ -619,8 +629,9 @@  discard block
 block discarded – undo
619 629
      */
620 630
     public static function archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)
621 631
     {
622
-        if (!is_dir($directory) || !is_readable($directory))
623
-            throw new InvalidArgumentException($directory.' is not a valid directory to archive');
632
+        if (!is_dir($directory) || !is_readable($directory)) {
633
+                    throw new InvalidArgumentException($directory.' is not a valid directory to archive');
634
+        }
624 635
 
625 636
         return static::archiveFiles($directory, $archiveName, $compressionLevel, $password) > 0;
626 637
     }
@@ -656,9 +667,9 @@  discard block
 block discarded – undo
656 667
         if (is_array($nodes)) {
657 668
             foreach ($nodes as $destination => $source) {
658 669
                 // new format
659
-                if (is_numeric($destination))
660
-                    $destination = $source;
661
-                else {
670
+                if (is_numeric($destination)) {
671
+                                    $destination = $source;
672
+                } else {
662 673
                     // old format
663 674
                     if (is_string($source) && !file_exists($source)) {
664 675
                         list($destination, $source) = [$source, $destination];
@@ -692,11 +703,12 @@  discard block
 block discarded – undo
692 703
 
693 704
         } else if (is_string($nodes)) { // passed one file or directory
694 705
             // if is directory
695
-            if (is_dir($nodes))
696
-                static::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true,
706
+            if (is_dir($nodes)) {
707
+                            static::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true,
697 708
                     $files);
698
-            else if (is_file($nodes))
699
-                $files[basename($nodes)] = $nodes;
709
+            } else if (is_file($nodes)) {
710
+                            $files[basename($nodes)] = $nodes;
711
+            }
700 712
         }
701 713
 
702 714
         return $files;
@@ -713,8 +725,9 @@  discard block
 block discarded – undo
713 725
         // $map[$destination] = rtrim($source, '/*');
714 726
         // do not map root archive folder
715 727
 
716
-        if ($destination !== null)
717
-            $map[$destination] = null;
728
+        if ($destination !== null) {
729
+                    $map[$destination] = null;
730
+        }
718 731
 
719 732
         foreach (glob($source, GLOB_MARK) as $node) {
720 733
             if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) {
Please login to merge, or discard this patch.
src/Formats.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -160,8 +160,9 @@
 block discarded – undo
160 160
         // by file content
161 161
         if ($contentCheck) {
162 162
             $mime_type = mime_content_type($fileName);
163
-            if (isset(static::$mimeTypes[$mime_type]))
164
-                return static::$mimeTypes[$mime_type];
163
+            if (isset(static::$mimeTypes[$mime_type])) {
164
+                            return static::$mimeTypes[$mime_type];
165
+            }
165 166
         }
166 167
 
167 168
         return false;
Please login to merge, or discard this patch.
src/Commands/DriversCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
             foreach ($typeDrivers as $typeDriverClass => $typeDriverConfig) {
60 60
                 $type_messages = [];
61 61
                 if ($typeDriverConfig[1]) {
62
-                    $type_messages[] = '<info>' . $typeDriverClass . '</info>: ' . $typeDriverConfig[0];
62
+                    $type_messages[] = '<info>'.$typeDriverClass.'</info>: '.$typeDriverConfig[0];
63 63
                 } else {
64
-                    $type_messages[] = '<error>' . $typeDriverClass . '</error>: ' . $typeDriverConfig[0];
64
+                    $type_messages[] = '<error>'.$typeDriverClass.'</error>: '.$typeDriverConfig[0];
65 65
                     $type_messages[] = $this->formatInstallation($typeDriverConfig[2], 4);
66 66
                 }
67 67
                 $output->writeln($formatter->formatSection(
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     protected function formatInstallation($doc, $leftPadding = 4)
85 85
     {
86 86
         return implode("\n", array_map(
87
-            function($line) use ($leftPadding) { return str_repeat(' ', $leftPadding) . $line; },
87
+            function($line) use ($leftPadding) { return str_repeat(' ', $leftPadding).$line; },
88 88
             explode(
89 89
                 "\n",
90 90
                 preg_replace('~`(.+?)`~', '<options=bold,underscore>$1</>', $doc)
Please login to merge, or discard this patch.
src/Commands/FormatsCommand.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,19 +33,19 @@  discard block
 block discarded – undo
33 33
 
34 34
         if ($driver !== null) {
35 35
             if (strpos($driver, '\\') === false) {
36
-                if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\' . $driver)) {
37
-                    $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\' . $driver;
38
-                } else if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\' . $driver)) {
39
-                    $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\' . $driver;
36
+                if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\'.$driver)) {
37
+                    $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\'.$driver;
38
+                } else if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\'.$driver)) {
39
+                    $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\'.$driver;
40 40
                 }
41 41
             }
42 42
             if ($driver[0] !== '\\') {
43 43
                 $driver = '\\'.$driver;
44 44
             }
45 45
             if (!class_exists($driver) || !is_a($driver, BasicDriver::class, true)) {
46
-                throw new \InvalidArgumentException('Class "' . $driver . '" not found or not in BasicDriver children');
46
+                throw new \InvalidArgumentException('Class "'.$driver.'" not found or not in BasicDriver children');
47 47
             }
48
-            $output->writeln('Supported formats by <info>' . $driver . '</info>');
48
+            $output->writeln('Supported formats by <info>'.$driver.'</info>');
49 49
 
50 50
             $table->setHeaders(['format', ...array_keys(self::$abilitiesLabels)]);
51 51
             foreach ($driver::getSupportedFormats() as $i => $format) {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             return 0;
63 63
         }
64 64
 
65
-        $headers = array_map(function ($v) { return substr($v, strrpos($v, '\\') + 1);}, Formats::$drivers);
65
+        $headers = array_map(function($v) { return substr($v, strrpos($v, '\\') + 1); }, Formats::$drivers);
66 66
         array_unshift($headers, 'format / driver');
67 67
 
68 68
         $table->setHeaders($headers);
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         $table->render();
89 89
 
90 90
         foreach (array_combine(array_values(self::$abilitiesShortCuts), array_keys(self::$abilitiesLabels)) as $shortCut => $label) {
91
-            $output->writeln('<info>' . $shortCut . '</info> - ' . $label);
91
+            $output->writeln('<info>'.$shortCut.'</info> - '.$label);
92 92
         }
93 93
 
94 94
         return 0;
Please login to merge, or discard this patch.
src/Drivers/OneFile/Lzma.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 class Lzma extends OneFileDriver
15 15
 {
16
-    const FORMAT_SUFFIX =  'xz';
16
+    const FORMAT_SUFFIX = 'xz';
17 17
     const PHP_EXTENSION = 'xz';
18 18
     const FORMAT = Formats::LZMA;
19 19
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public static function getInstallationInstruction()
32 32
     {
33
-        return 'install [xz] extension' . "\n" . 'For 5.x: https://github.com/payden/php-xz' . "\n" . 'For 7.x: https://github.com/codemasher/php-ext-xz';
33
+        return 'install [xz] extension'."\n".'For 5.x: https://github.com/payden/php-xz'."\n".'For 7.x: https://github.com/codemasher/php-ext-xz';
34 34
     }
35 35
 
36 36
     /**
Please login to merge, or discard this patch.
src/Drivers/OneFile/Bzip.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 
8 8
 class Bzip extends OneFileDriver
9 9
 {
10
-    const FORMAT_SUFFIX =  'bz2';
10
+    const FORMAT_SUFFIX = 'bz2';
11 11
     const PHP_EXTENSION = 'bz2';
12 12
     const FORMAT = Formats::BZIP;
13 13
 
Please login to merge, or discard this patch.