Passed
Push — master ( afad4e...ae0184 )
by f
40:32 queued 25:34
created
src/UnifiedArchive.php 1 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.