Passed
Push — master ( ae0184...ccf027 )
by f
13:17
created
src/UnifiedArchive.php 1 patch
Braces   +38 added lines, -27 removed lines patch added patch discarded remove patch
@@ -127,8 +127,9 @@  discard block
 block discarded – undo
127 127
 
128 128
         $files_list = static::createFilesList($fileOrFiles);
129 129
 
130
-        if (empty($files_list))
131
-            throw new EmptyFileListException('Files list is empty!');
130
+        if (empty($files_list)) {
131
+                    throw new EmptyFileListException('Files list is empty!');
132
+        }
132 133
 
133 134
         $totalSize = 0;
134 135
         foreach ($files_list as $fn) {
@@ -182,18 +183,21 @@  discard block
 block discarded – undo
182 183
         $fileProgressCallable = null
183 184
     )
184 185
     {
185
-        if (file_exists($archiveName))
186
-            throw new FileAlreadyExistsException('Archive ' . $archiveName . ' already exists!');
186
+        if (file_exists($archiveName)) {
187
+                    throw new FileAlreadyExistsException('Archive ' . $archiveName . ' already exists!');
188
+        }
187 189
 
188 190
         $info = static::prepareForArchiving($fileOrFiles, $archiveName);
189 191
 
190 192
         $abilities = [BasicDriver::CREATE];
191 193
 
192
-        if (!Formats::canCreate($info['type']))
193
-            throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ' . $archiveName);
194
+        if (!Formats::canCreate($info['type'])) {
195
+                    throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ' . $archiveName);
196
+        }
194 197
 
195
-        if ($password !== null && !Formats::canEncrypt($info['type']))
196
-            throw new UnsupportedOperationException('Archive type ' . $info['type'] . ' can not be encrypted');
198
+        if ($password !== null && !Formats::canEncrypt($info['type'])) {
199
+                    throw new UnsupportedOperationException('Archive type ' . $info['type'] . ' can not be encrypted');
200
+        }
197 201
         if ($password !== null) {
198 202
             $abilities[] = BasicDriver::CREATE_ENCRYPTED;
199 203
         }
@@ -311,8 +315,9 @@  discard block
 block discarded – undo
311 315
      */
312 316
     public static function archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)
313 317
     {
314
-        if (!is_dir($directory) || !is_readable($directory))
315
-            throw new InvalidArgumentException($directory . ' is not a valid directory to archive');
318
+        if (!is_dir($directory) || !is_readable($directory)) {
319
+                    throw new InvalidArgumentException($directory . ' is not a valid directory to archive');
320
+        }
316 321
 
317 322
         return static::archive($directory, $archiveName, $compressionLevel, $password) > 0;
318 323
     }
@@ -482,13 +487,15 @@  discard block
 block discarded – undo
482 487
      */
483 488
     public function getFiles($filter = null)
484 489
     {
485
-        if ($filter === null)
486
-            return $this->files;
490
+        if ($filter === null) {
491
+                    return $this->files;
492
+        }
487 493
 
488 494
         $result = [];
489 495
         foreach ($this->files as $file) {
490
-            if (fnmatch($filter, $file))
491
-                $result[] = $file;
496
+            if (fnmatch($filter, $file)) {
497
+                            $result[] = $file;
498
+            }
492 499
         }
493 500
         return $result;
494 501
     }
@@ -632,8 +639,9 @@  discard block
 block discarded – undo
632 639
      */
633 640
     public function addFile($file, $inArchiveName = null)
634 641
     {
635
-        if (!is_file($file))
636
-            throw new InvalidArgumentException($file . ' is not a valid file to add in archive');
642
+        if (!is_file($file)) {
643
+                    throw new InvalidArgumentException($file . ' is not a valid file to add in archive');
644
+        }
637 645
 
638 646
         return ($inArchiveName !== null
639 647
                 ? $this->add([$inArchiveName => $file])
@@ -666,8 +674,9 @@  discard block
 block discarded – undo
666 674
      */
667 675
     public function addDirectory($directory, $inArchivePath = null)
668 676
     {
669
-        if (!is_dir($directory) || !is_readable($directory))
670
-            throw new InvalidArgumentException($directory . ' is not a valid directory to add in archive');
677
+        if (!is_dir($directory) || !is_readable($directory)) {
678
+                    throw new InvalidArgumentException($directory . ' is not a valid directory to add in archive');
679
+        }
671 680
 
672 681
         return ($inArchivePath !== null
673 682
                 ? $this->add([$inArchivePath => $directory])
@@ -730,9 +739,9 @@  discard block
 block discarded – undo
730 739
         if (is_array($nodes)) {
731 740
             foreach ($nodes as $destination => $source) {
732 741
                 // new format
733
-                if (is_numeric($destination))
734
-                    $destination = $source;
735
-                else {
742
+                if (is_numeric($destination)) {
743
+                                    $destination = $source;
744
+                } else {
736 745
                     // old format
737 746
                     if (is_string($source) && !file_exists($source)) {
738 747
                         list($destination, $source) = [$source, $destination];
@@ -766,11 +775,12 @@  discard block
 block discarded – undo
766 775
 
767 776
         } else if (is_string($nodes)) { // passed one file or directory
768 777
             // if is directory
769
-            if (is_dir($nodes))
770
-                static::importFilesFromDir(rtrim($nodes, '/\\*') . '/*', null, true,
778
+            if (is_dir($nodes)) {
779
+                            static::importFilesFromDir(rtrim($nodes, '/\\*') . '/*', null, true,
771 780
                     $files);
772
-            else if (is_file($nodes))
773
-                $files[basename($nodes)] = $nodes;
781
+            } else if (is_file($nodes)) {
782
+                            $files[basename($nodes)] = $nodes;
783
+            }
774 784
         }
775 785
 
776 786
         return $files;
@@ -787,8 +797,9 @@  discard block
 block discarded – undo
787 797
         // $map[$destination] = rtrim($source, '/*');
788 798
         // do not map root archive folder
789 799
 
790
-        if ($destination !== null)
791
-            $map[$destination] = null;
800
+        if ($destination !== null) {
801
+                    $map[$destination] = null;
802
+        }
792 803
 
793 804
         foreach (glob($source, GLOB_MARK) as $node) {
794 805
             if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) {
Please login to merge, or discard this patch.