Passed
Push — master ( ae0184...ccf027 )
by f
13:17
created
src/Drivers/BasicDriver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@
 block discarded – undo
129 129
     ) {
130 130
         $format_extension = Formats::getFormatExtension($archiveFormat);
131 131
         do {
132
-            $temp_file = tempnam(sys_get_temp_dir(), 'temp_archive') . '.' . $format_extension;
132
+            $temp_file = tempnam(sys_get_temp_dir(), 'temp_archive').'.'.$format_extension;
133 133
         } while (file_exists($temp_file));
134 134
 
135 135
         $created = static::createArchive($files, $temp_file, $archiveFormat, $compressionLevel, $password, $fileProgressCallable);
Please login to merge, or discard this patch.
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);
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         if ($archiveName !== null) {
122 122
             $archiveType = Formats::detectArchiveFormat($archiveName, false);
123 123
             if ($archiveType === false) {
124
-                throw new UnsupportedArchiveException('Could not detect archive type for name "' . $archiveName . '"');
124
+                throw new UnsupportedArchiveException('Could not detect archive type for name "'.$archiveName.'"');
125 125
             }
126 126
         }
127 127
 
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
     )
184 184
     {
185 185
         if (file_exists($archiveName))
186
-            throw new FileAlreadyExistsException('Archive ' . $archiveName . ' already exists!');
186
+            throw new FileAlreadyExistsException('Archive '.$archiveName.' already exists!');
187 187
 
188 188
         $info = static::prepareForArchiving($fileOrFiles, $archiveName);
189 189
 
190 190
         $abilities = [BasicDriver::CREATE];
191 191
 
192 192
         if (!Formats::canCreate($info['type']))
193
-            throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ' . $archiveName);
193
+            throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '.$archiveName);
194 194
 
195 195
         if ($password !== null && !Formats::canEncrypt($info['type']))
196
-            throw new UnsupportedOperationException('Archive type ' . $info['type'] . ' can not be encrypted');
196
+            throw new UnsupportedOperationException('Archive type '.$info['type'].' can not be encrypted');
197 197
         if ($password !== null) {
198 198
             $abilities[] = BasicDriver::CREATE_ENCRYPTED;
199 199
         }
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
         /** @var BasicDriver $driver */
202 202
         $driver = Formats::getFormatDriver($info['type'], $abilities);
203 203
         if ($driver === null) {
204
-            throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ');
204
+            throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive ');
205 205
         }
206 206
 
207 207
         return $driver::createArchive(
@@ -253,11 +253,11 @@  discard block
 block discarded – undo
253 253
         $info = static::prepareForArchiving($fileOrFiles);
254 254
         $abilities = [BasicDriver::CREATE, BasicDriver::CREATE_IN_STRING];
255 255
         if (!Formats::canCreate($info['type'])) {
256
-            throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ' . $archiveName);
256
+            throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '.$archiveName);
257 257
         }
258 258
 
259 259
         if ($password !== null && !Formats::canEncrypt($info['type'])) {
260
-            throw new UnsupportedOperationException('Archive type ' . $info['type'] . ' can not be encrypted');
260
+            throw new UnsupportedOperationException('Archive type '.$info['type'].' can not be encrypted');
261 261
         }
262 262
         if ($password !== null) {
263 263
             $abilities[] = BasicDriver::CREATE_ENCRYPTED;
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
         /** @var BasicDriver $driver */
267 267
         $driver = Formats::getFormatDriver($info['type'], $abilities);
268 268
         if ($driver === null) {
269
-            throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ');
269
+            throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive ');
270 270
         }
271 271
 
272 272
         return $driver::createArchiveInString(
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
     public static function archiveFile($file, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)
293 293
     {
294 294
         if (!is_file($file)) {
295
-            throw new InvalidArgumentException($file . ' is not a valid file to archive');
295
+            throw new InvalidArgumentException($file.' is not a valid file to archive');
296 296
         }
297 297
 
298 298
         return static::archive($file, $archiveName, $compressionLevel, $password) === 1;
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
     public static function archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)
313 313
     {
314 314
         if (!is_dir($directory) || !is_readable($directory))
315
-            throw new InvalidArgumentException($directory . ' is not a valid directory to archive');
315
+            throw new InvalidArgumentException($directory.' is not a valid directory to archive');
316 316
 
317 317
         return static::archive($directory, $archiveName, $compressionLevel, $password) > 0;
318 318
     }
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
     public function getFileData($fileName)
504 504
     {
505 505
         if (!in_array($fileName, $this->files, true)) {
506
-            throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive');
506
+            throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive');
507 507
         }
508 508
 
509 509
         return $this->archive->getFileData($fileName);
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
     public function getFileContent($fileName)
520 520
     {
521 521
         if (!in_array($fileName, $this->files, true)) {
522
-            throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive');
522
+            throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive');
523 523
         }
524 524
 
525 525
         return $this->archive->getFileContent($fileName);
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
     public function getFileStream($fileName)
536 536
     {
537 537
         if (!in_array($fileName, $this->files, true)) {
538
-            throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive');
538
+            throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive');
539 539
         }
540 540
 
541 541
         return $this->archive->getFileStream($fileName);
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
     public function addFile($file, $inArchiveName = null)
634 634
     {
635 635
         if (!is_file($file))
636
-            throw new InvalidArgumentException($file . ' is not a valid file to add in archive');
636
+            throw new InvalidArgumentException($file.' is not a valid file to add in archive');
637 637
 
638 638
         return ($inArchiveName !== null
639 639
                 ? $this->add([$inArchiveName => $file])
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
     public function addDirectory($directory, $inArchivePath = null)
668 668
     {
669 669
         if (!is_dir($directory) || !is_readable($directory))
670
-            throw new InvalidArgumentException($directory . ' is not a valid directory to add in archive');
670
+            throw new InvalidArgumentException($directory.' is not a valid directory to add in archive');
671 671
 
672 672
         return ($inArchivePath !== null
673 673
                 ? $this->add([$inArchivePath => $directory])
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
         $newFiles = [];
711 711
         foreach ($files as $file) {
712 712
             foreach ($archiveFiles as $archiveFile) {
713
-                if (fnmatch($file . '*', $archiveFile)) {
713
+                if (fnmatch($file.'*', $archiveFile)) {
714 714
                     $newFiles[] = $archiveFile;
715 715
                 }
716 716
             }
@@ -745,8 +745,8 @@  discard block
 block discarded – undo
745 745
                 if (is_array($source)) {
746 746
                     foreach ($source as $sourceItem) {
747 747
                         static::importFilesFromDir(
748
-                            rtrim($sourceItem, '/\\*') . '/*',
749
-                            !empty($destination) ? $destination . '/' : null,
748
+                            rtrim($sourceItem, '/\\*').'/*',
749
+                            !empty($destination) ? $destination.'/' : null,
750 750
                             true,
751 751
                             $files
752 752
                         );
@@ -754,8 +754,8 @@  discard block
 block discarded – undo
754 754
                 } else if (is_dir($source)) {
755 755
                     // one source for directories
756 756
                     static::importFilesFromDir(
757
-                        rtrim($source, '/\\*') . '/*',
758
-                        !empty($destination) ? $destination . '/' : null,
757
+                        rtrim($source, '/\\*').'/*',
758
+                        !empty($destination) ? $destination.'/' : null,
759 759
                         true,
760 760
                         $files
761 761
                     );
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
         } else if (is_string($nodes)) { // passed one file or directory
768 768
             // if is directory
769 769
             if (is_dir($nodes))
770
-                static::importFilesFromDir(rtrim($nodes, '/\\*') . '/*', null, true,
770
+                static::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true,
771 771
                     $files);
772 772
             else if (is_file($nodes))
773 773
                 $files[basename($nodes)] = $nodes;
@@ -792,10 +792,10 @@  discard block
 block discarded – undo
792 792
 
793 793
         foreach (glob($source, GLOB_MARK) as $node) {
794 794
             if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) {
795
-                static::importFilesFromDir(str_replace('\\', '/', $node) . '*',
796
-                    $destination . basename($node) . '/', $recursive, $map);
795
+                static::importFilesFromDir(str_replace('\\', '/', $node).'*',
796
+                    $destination.basename($node).'/', $recursive, $map);
797 797
             } elseif (is_file($node) && is_readable($node)) {
798
-                $map[$destination . basename($node)] = $node;
798
+                $map[$destination.basename($node)] = $node;
799 799
             }
800 800
         }
801 801
     }
Please login to merge, or discard this 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.