Passed
Push — master ( afad4e...ae0184 )
by f
40:32 queued 25:34
created
src/UnifiedArchive.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     public static function open($fileName, $abilities = [], $password = null)
65 65
     {
66 66
         if (!file_exists($fileName) || !is_readable($fileName)) {
67
-            throw new InvalidArgumentException('Could not open file: ' . $fileName . ' is not readable');
67
+            throw new InvalidArgumentException('Could not open file: '.$fileName.' is not readable');
68 68
         }
69 69
 
70 70
         $format = Formats::detectArchiveFormat($fileName);
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
     public function getFileData($fileName)
288 288
     {
289 289
         if (!in_array($fileName, $this->files, true)) {
290
-            throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive');
290
+            throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive');
291 291
         }
292 292
 
293 293
         return $this->archive->getFileData($fileName);
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
     public function getFileContent($fileName)
304 304
     {
305 305
         if (!in_array($fileName, $this->files, true)) {
306
-            throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive');
306
+            throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive');
307 307
         }
308 308
 
309 309
         return $this->archive->getFileContent($fileName);
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     public function getFileStream($fileName)
320 320
     {
321 321
         if (!in_array($fileName, $this->files, true)) {
322
-            throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive');
322
+            throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive');
323 323
         }
324 324
 
325 325
         return $this->archive->getFileStream($fileName);
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
     public function addFile($file, $inArchiveName = null)
417 417
     {
418 418
         if (!is_file($file))
419
-            throw new InvalidArgumentException($file . ' is not a valid file to add in archive');
419
+            throw new InvalidArgumentException($file.' is not a valid file to add in archive');
420 420
 
421 421
         return ($inArchiveName !== null
422 422
                 ? $this->add([$inArchiveName => $file])
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
     public function addDirectory($directory, $inArchivePath = null)
451 451
     {
452 452
         if (!is_dir($directory) || !is_readable($directory))
453
-            throw new InvalidArgumentException($directory . ' is not a valid directory to add in archive');
453
+            throw new InvalidArgumentException($directory.' is not a valid directory to add in archive');
454 454
 
455 455
         return ($inArchivePath !== null
456 456
                 ? $this->add([$inArchivePath => $directory])
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
         if ($archiveName !== null) {
501 501
             $archiveType = Formats::detectArchiveFormat($archiveName, false);
502 502
             if ($archiveType === false) {
503
-                throw new UnsupportedArchiveException('Could not detect archive type for name "' . $archiveName . '"');
503
+                throw new UnsupportedArchiveException('Could not detect archive type for name "'.$archiveName.'"');
504 504
             }
505 505
         }
506 506
 
@@ -562,17 +562,17 @@  discard block
 block discarded – undo
562 562
     )
563 563
     {
564 564
         if (file_exists($archiveName))
565
-            throw new FileAlreadyExistsException('Archive ' . $archiveName . ' already exists!');
565
+            throw new FileAlreadyExistsException('Archive '.$archiveName.' already exists!');
566 566
 
567 567
         $info = static::prepareForArchiving($fileOrFiles, $archiveName);
568 568
 
569 569
         $abilities = [BasicDriver::CREATE];
570 570
 
571 571
         if (!Formats::canCreate($info['type']))
572
-            throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ' . $archiveName);
572
+            throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '.$archiveName);
573 573
 
574 574
         if ($password !== null && !Formats::canEncrypt($info['type']))
575
-            throw new UnsupportedOperationException('Archive type ' . $info['type'] . ' can not be encrypted');
575
+            throw new UnsupportedOperationException('Archive type '.$info['type'].' can not be encrypted');
576 576
         if ($password !== null) {
577 577
             $abilities[] = BasicDriver::CREATE_ENCRYPTED;
578 578
         }
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
         /** @var BasicDriver $driver */
581 581
         $driver = Formats::getFormatDriver($info['type'], $abilities);
582 582
         if ($driver === null) {
583
-            throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ');
583
+            throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive ');
584 584
         }
585 585
 
586 586
         return $driver::createArchive(
@@ -632,11 +632,11 @@  discard block
 block discarded – undo
632 632
         $info = static::prepareForArchiving($fileOrFiles);
633 633
         $abilities = [BasicDriver::CREATE, BasicDriver::CREATE_IN_STRING];
634 634
         if (!Formats::canCreate($info['type'])) {
635
-            throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ' . $archiveName);
635
+            throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '.$archiveName);
636 636
         }
637 637
 
638 638
         if ($password !== null && !Formats::canEncrypt($info['type'])) {
639
-            throw new UnsupportedOperationException('Archive type ' . $info['type'] . ' can not be encrypted');
639
+            throw new UnsupportedOperationException('Archive type '.$info['type'].' can not be encrypted');
640 640
         }
641 641
         if ($password !== null) {
642 642
             $abilities[] = BasicDriver::CREATE_ENCRYPTED;
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
         /** @var BasicDriver $driver */
646 646
         $driver = Formats::getFormatDriver($info['type'], $abilities);
647 647
         if ($driver === null) {
648
-            throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ');
648
+            throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive ');
649 649
         }
650 650
 
651 651
         return $driver::createArchiveInString(
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
     public static function archiveFile($file, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)
672 672
     {
673 673
         if (!is_file($file)) {
674
-            throw new InvalidArgumentException($file . ' is not a valid file to archive');
674
+            throw new InvalidArgumentException($file.' is not a valid file to archive');
675 675
         }
676 676
 
677 677
         return static::archive($file, $archiveName, $compressionLevel, $password) === 1;
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
     public static function archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)
692 692
     {
693 693
         if (!is_dir($directory) || !is_readable($directory))
694
-            throw new InvalidArgumentException($directory . ' is not a valid directory to archive');
694
+            throw new InvalidArgumentException($directory.' is not a valid directory to archive');
695 695
 
696 696
         return static::archive($directory, $archiveName, $compressionLevel, $password) > 0;
697 697
     }
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
         $newFiles = [];
708 708
         foreach ($files as $file) {
709 709
             foreach ($archiveFiles as $archiveFile) {
710
-                if (fnmatch($file . '*', $archiveFile)) {
710
+                if (fnmatch($file.'*', $archiveFile)) {
711 711
                     $newFiles[] = $archiveFile;
712 712
                 }
713 713
             }
@@ -742,8 +742,8 @@  discard block
 block discarded – undo
742 742
                 if (is_array($source)) {
743 743
                     foreach ($source as $sourceItem) {
744 744
                         static::importFilesFromDir(
745
-                            rtrim($sourceItem, '/\\*') . '/*',
746
-                            !empty($destination) ? $destination . '/' : null,
745
+                            rtrim($sourceItem, '/\\*').'/*',
746
+                            !empty($destination) ? $destination.'/' : null,
747 747
                             true,
748 748
                             $files
749 749
                         );
@@ -751,8 +751,8 @@  discard block
 block discarded – undo
751 751
                 } else if (is_dir($source)) {
752 752
                     // one source for directories
753 753
                     static::importFilesFromDir(
754
-                        rtrim($source, '/\\*') . '/*',
755
-                        !empty($destination) ? $destination . '/' : null,
754
+                        rtrim($source, '/\\*').'/*',
755
+                        !empty($destination) ? $destination.'/' : null,
756 756
                         true,
757 757
                         $files
758 758
                     );
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
         } else if (is_string($nodes)) { // passed one file or directory
765 765
             // if is directory
766 766
             if (is_dir($nodes))
767
-                static::importFilesFromDir(rtrim($nodes, '/\\*') . '/*', null, true,
767
+                static::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true,
768 768
                     $files);
769 769
             else if (is_file($nodes))
770 770
                 $files[basename($nodes)] = $nodes;
@@ -789,10 +789,10 @@  discard block
 block discarded – undo
789 789
 
790 790
         foreach (glob($source, GLOB_MARK) as $node) {
791 791
             if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) {
792
-                static::importFilesFromDir(str_replace('\\', '/', $node) . '*',
793
-                    $destination . basename($node) . '/', $recursive, $map);
792
+                static::importFilesFromDir(str_replace('\\', '/', $node).'*',
793
+                    $destination.basename($node).'/', $recursive, $map);
794 794
             } elseif (is_file($node) && is_readable($node)) {
795
-                $map[$destination . basename($node)] = $node;
795
+                $map[$destination.basename($node)] = $node;
796 796
             }
797 797
         }
798 798
     }
Please login to merge, or discard this patch.
Braces   +41 added lines, -29 removed lines patch added patch discarded remove patch
@@ -266,13 +266,15 @@  discard block
 block discarded – undo
266 266
      */
267 267
     public function getFiles($filter = null)
268 268
     {
269
-        if ($filter === null)
270
-            return $this->files;
269
+        if ($filter === null) {
270
+                    return $this->files;
271
+        }
271 272
 
272 273
         $result = [];
273 274
         foreach ($this->files as $file) {
274
-            if (fnmatch($filter, $file))
275
-                $result[] = $file;
275
+            if (fnmatch($filter, $file)) {
276
+                            $result[] = $file;
277
+            }
276 278
         }
277 279
         return $result;
278 280
     }
@@ -395,8 +397,9 @@  discard block
 block discarded – undo
395 397
     {
396 398
         $files_list = static::createFilesList($fileOrFiles);
397 399
 
398
-        if (empty($files_list))
399
-            throw new EmptyFileListException('Files list is empty!');
400
+        if (empty($files_list)) {
401
+                    throw new EmptyFileListException('Files list is empty!');
402
+        }
400 403
 
401 404
         $result = $this->archive->addFiles($files_list);
402 405
         $this->scanArchive();
@@ -415,8 +418,9 @@  discard block
 block discarded – undo
415 418
      */
416 419
     public function addFile($file, $inArchiveName = null)
417 420
     {
418
-        if (!is_file($file))
419
-            throw new InvalidArgumentException($file . ' is not a valid file to add in archive');
421
+        if (!is_file($file)) {
422
+                    throw new InvalidArgumentException($file . ' is not a valid file to add in archive');
423
+        }
420 424
 
421 425
         return ($inArchiveName !== null
422 426
                 ? $this->add([$inArchiveName => $file])
@@ -449,8 +453,9 @@  discard block
 block discarded – undo
449 453
      */
450 454
     public function addDirectory($directory, $inArchivePath = null)
451 455
     {
452
-        if (!is_dir($directory) || !is_readable($directory))
453
-            throw new InvalidArgumentException($directory . ' is not a valid directory to add in archive');
456
+        if (!is_dir($directory) || !is_readable($directory)) {
457
+                    throw new InvalidArgumentException($directory . ' is not a valid directory to add in archive');
458
+        }
454 459
 
455 460
         return ($inArchivePath !== null
456 461
                 ? $this->add([$inArchivePath => $directory])
@@ -506,8 +511,9 @@  discard block
 block discarded – undo
506 511
 
507 512
         $files_list = static::createFilesList($fileOrFiles);
508 513
 
509
-        if (empty($files_list))
510
-            throw new EmptyFileListException('Files list is empty!');
514
+        if (empty($files_list)) {
515
+                    throw new EmptyFileListException('Files list is empty!');
516
+        }
511 517
 
512 518
         $totalSize = 0;
513 519
         foreach ($files_list as $fn) {
@@ -561,18 +567,21 @@  discard block
 block discarded – undo
561 567
         $fileProgressCallable = null
562 568
     )
563 569
     {
564
-        if (file_exists($archiveName))
565
-            throw new FileAlreadyExistsException('Archive ' . $archiveName . ' already exists!');
570
+        if (file_exists($archiveName)) {
571
+                    throw new FileAlreadyExistsException('Archive ' . $archiveName . ' already exists!');
572
+        }
566 573
 
567 574
         $info = static::prepareForArchiving($fileOrFiles, $archiveName);
568 575
 
569 576
         $abilities = [BasicDriver::CREATE];
570 577
 
571
-        if (!Formats::canCreate($info['type']))
572
-            throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ' . $archiveName);
578
+        if (!Formats::canCreate($info['type'])) {
579
+                    throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ' . $archiveName);
580
+        }
573 581
 
574
-        if ($password !== null && !Formats::canEncrypt($info['type']))
575
-            throw new UnsupportedOperationException('Archive type ' . $info['type'] . ' can not be encrypted');
582
+        if ($password !== null && !Formats::canEncrypt($info['type'])) {
583
+                    throw new UnsupportedOperationException('Archive type ' . $info['type'] . ' can not be encrypted');
584
+        }
576 585
         if ($password !== null) {
577 586
             $abilities[] = BasicDriver::CREATE_ENCRYPTED;
578 587
         }
@@ -690,8 +699,9 @@  discard block
 block discarded – undo
690 699
      */
691 700
     public static function archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)
692 701
     {
693
-        if (!is_dir($directory) || !is_readable($directory))
694
-            throw new InvalidArgumentException($directory . ' is not a valid directory to archive');
702
+        if (!is_dir($directory) || !is_readable($directory)) {
703
+                    throw new InvalidArgumentException($directory . ' is not a valid directory to archive');
704
+        }
695 705
 
696 706
         return static::archive($directory, $archiveName, $compressionLevel, $password) > 0;
697 707
     }
@@ -727,9 +737,9 @@  discard block
 block discarded – undo
727 737
         if (is_array($nodes)) {
728 738
             foreach ($nodes as $destination => $source) {
729 739
                 // new format
730
-                if (is_numeric($destination))
731
-                    $destination = $source;
732
-                else {
740
+                if (is_numeric($destination)) {
741
+                                    $destination = $source;
742
+                } else {
733 743
                     // old format
734 744
                     if (is_string($source) && !file_exists($source)) {
735 745
                         list($destination, $source) = [$source, $destination];
@@ -763,11 +773,12 @@  discard block
 block discarded – undo
763 773
 
764 774
         } else if (is_string($nodes)) { // passed one file or directory
765 775
             // if is directory
766
-            if (is_dir($nodes))
767
-                static::importFilesFromDir(rtrim($nodes, '/\\*') . '/*', null, true,
776
+            if (is_dir($nodes)) {
777
+                            static::importFilesFromDir(rtrim($nodes, '/\\*') . '/*', null, true,
768 778
                     $files);
769
-            else if (is_file($nodes))
770
-                $files[basename($nodes)] = $nodes;
779
+            } else if (is_file($nodes)) {
780
+                            $files[basename($nodes)] = $nodes;
781
+            }
771 782
         }
772 783
 
773 784
         return $files;
@@ -784,8 +795,9 @@  discard block
 block discarded – undo
784 795
         // $map[$destination] = rtrim($source, '/*');
785 796
         // do not map root archive folder
786 797
 
787
-        if ($destination !== null)
788
-            $map[$destination] = null;
798
+        if ($destination !== null) {
799
+                    $map[$destination] = null;
800
+        }
789 801
 
790 802
         foreach (glob($source, GLOB_MARK) as $node) {
791 803
             if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) {
Please login to merge, or discard this patch.