Passed
Push — 1.1.x ( bc52f7...e8e75c )
by f
12:04
created
src/Commands/DetailsCommand.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,8 +41,9 @@
 block discarded – undo
41 41
         $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($details->compressedSize, 2)));
42 42
         $output->writeln("\t" . 'ratio: <info>' . round($details->uncompressedSize / $details->compressedSize, 6) . '/1 (' . floor($details->compressedSize / $details->uncompressedSize * 100) . '%</info>)');
43 43
         $output->writeln('Modificated: ' . $this->formatDate($details->modificationTime));
44
-        if (!empty($comment = $details->comment))
45
-            $output->writeln('Comment: <comment>' . $comment . '</comment>');
44
+        if (!empty($comment = $details->comment)) {
45
+                    $output->writeln('Comment: <comment>' . $comment . '</comment>');
46
+        }
46 47
 
47 48
         if (empty($input->getArgument('file'))) {
48 49
             $helper = $this->getHelper('question');
Please login to merge, or discard this patch.
src/Commands/CreateCommand.php 1 patch
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -58,9 +58,9 @@
 block discarded – undo
58 58
         $comment = $input->getOption('comment');
59 59
 
60 60
         if (file_exists($archive_file)) {
61
-            if (is_dir($archive_file))
62
-                throw new \InvalidArgumentException($archive_file . ' is a directory!');
63
-            else {
61
+            if (is_dir($archive_file)) {
62
+                            throw new \InvalidArgumentException($archive_file . ' is a directory!');
63
+            } else {
64 64
                 throw new \InvalidArgumentException('File "' . $archive_file . '" already exists!');
65 65
             }
66 66
         }
Please login to merge, or discard this patch.
src/PclZipInterface.php 1 patch
Braces   +99 added lines, -57 removed lines patch added patch discarded remove patch
@@ -137,8 +137,11 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public function create($content)
139 139
     {
140
-        if (is_array($content)) $paths_list = $content;
141
-        else $paths_list = explode(',', $content);
140
+        if (is_array($content)) {
141
+         $paths_list = $content;
142
+        } else {
143
+         $paths_list = explode(',', $content);
144
+        }
142 145
 
143 146
         $options = $this->makeOptionsFromArguments(func_get_args());
144 147
 
@@ -146,8 +149,9 @@  discard block
 block discarded – undo
146 149
         $filters = $this->createFilters($options);
147 150
         list($preAddCallback, $postAddCallback) = $this->extractCallbacks($options, PCLZIP_CB_PRE_ADD, PCLZIP_CB_POST_ADD);
148 151
 
149
-        if (!empty($comment = $this->buildComment($options, null)))
150
-            $this->archive->setComment($comment);
152
+        if (!empty($comment = $this->buildComment($options, null))) {
153
+                    $this->archive->setComment($comment);
154
+        }
151 155
 
152 156
         // scan filesystem for files list
153 157
         return $this->addSnippets($paths_list, $filters, $preAddCallback, $postAddCallback);
@@ -167,16 +171,18 @@  discard block
 block discarded – undo
167 171
             $localname = $fileToAdd;
168 172
             $filename = $fileToAdd;
169 173
 
170
-            foreach ($filters as $filter)
171
-                call_user_func($filter, $localname, $filename);
174
+            foreach ($filters as $filter) {
175
+                            call_user_func($filter, $localname, $filename);
176
+            }
172 177
 
173 178
             $file_header = $this->createFileHeader($localname, $filename);
174 179
             if (call_user_func($preAddCallback, $file_header) == 1) {
175 180
                 //
176 181
                 // Check for max length > 255
177 182
                 //
178
-                if (strlen(basename($file_header->stored_filename)) > 255)
179
-                    $file_header->status = 'filename_too_long';
183
+                if (strlen(basename($file_header->stored_filename)) > 255) {
184
+                                    $file_header->status = 'filename_too_long';
185
+                }
180 186
                 if (is_file($filename)) {
181 187
                     $this->archive->addFiles([
182 188
                         $file_header->stored_filename => $file_header->filename,
@@ -248,27 +254,35 @@  discard block
 block discarded – undo
248 254
         }
249 255
 
250 256
         // filters initiation
251
-        if (isset($options[PCLZIP_OPT_PATH]))
252
-            $extractPath = rtrim($options[PCLZIP_OPT_PATH], '/');
253
-        else $extractPath = rtrim(getcwd(), '/');
257
+        if (isset($options[PCLZIP_OPT_PATH])) {
258
+                    $extractPath = rtrim($options[PCLZIP_OPT_PATH], '/');
259
+        } else {
260
+         $extractPath = rtrim(getcwd(), '/');
261
+        }
254 262
 
255 263
         $filters = $this->createFilters($options);
256 264
         list($preExtractCallback, $postExtractCallback) = $this->extractCallbacks($options, PCLZIP_CB_PRE_EXTRACT, PCLZIP_CB_POST_EXTRACT);
257 265
         $selectFilter = $this->createSelector($options);
258 266
 
259
-        if (isset($options[PCLZIP_OPT_EXTRACT_AS_STRING]))
260
-            $anotherOutputFormat = PCLZIP_OPT_EXTRACT_AS_STRING;
261
-        else if (isset($options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
262
-            $anotherOutputFormat = PCLZIP_OPT_EXTRACT_IN_OUTPUT;
263
-        else $anotherOutputFormat = false;
267
+        if (isset($options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
268
+                    $anotherOutputFormat = PCLZIP_OPT_EXTRACT_AS_STRING;
269
+        } else if (isset($options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
270
+                    $anotherOutputFormat = PCLZIP_OPT_EXTRACT_IN_OUTPUT;
271
+        } else {
272
+         $anotherOutputFormat = false;
273
+        }
264 274
 
265
-        if (isset($options[PCLZIP_OPT_REPLACE_NEWER]))
266
-            $doNotReplaceNewer = false;
267
-        else $doNotReplaceNewer = true;
275
+        if (isset($options[PCLZIP_OPT_REPLACE_NEWER])) {
276
+                    $doNotReplaceNewer = false;
277
+        } else {
278
+         $doNotReplaceNewer = true;
279
+        }
268 280
 
269
-        if (isset($options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION]))
270
-            $restrictExtractDir = $options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION];
271
-        else $restrictExtractDir = false;
281
+        if (isset($options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
282
+                    $restrictExtractDir = $options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION];
283
+        } else {
284
+         $restrictExtractDir = false;
285
+        }
272 286
 
273 287
         $report = array();
274 288
         foreach ($this->listContent() as $file_header) {
@@ -339,8 +353,10 @@  discard block
 block discarded – undo
339 353
             // extract content
340 354
             else if ($anotherOutputFormat === false) {
341 355
                 // apply path filters
342
-                foreach ($filters as $filter) call_user_func($filter,
356
+                foreach ($filters as $filter) {
357
+                 call_user_func($filter,
343 358
                     $file_header->stored_filename, $file_header->filename);
359
+                }
344 360
                 // dir extraction process
345 361
                 if ($file_header->folder) {
346 362
                     // if dir doesn't exist
@@ -431,15 +447,19 @@  discard block
 block discarded – undo
431 447
      */
432 448
     public function add($content)
433 449
     {
434
-        if (is_array($content)) $paths_list = $content;
435
-        else $paths_list = explode(',', $content);
450
+        if (is_array($content)) {
451
+         $paths_list = $content;
452
+        } else {
453
+         $paths_list = explode(',', $content);
454
+        }
436 455
 
437 456
         $options = $this->makeOptionsFromArguments(func_get_args());
438 457
         $filters = $this->createFilters($options);
439 458
         list($preAddCallback, $postAddCallback) = $this->extractCallbacks($options, PCLZIP_CB_PRE_ADD, PCLZIP_CB_POST_ADD);
440 459
 
441
-        if (!empty($comment = $this->buildComment($options, $this->archive->getComment())))
442
-            $this->archive->setComment($comment);
460
+        if (!empty($comment = $this->buildComment($options, $this->archive->getComment()))) {
461
+                    $this->archive->setComment($comment);
462
+        }
443 463
 
444 464
         // scan filesystem for files list
445 465
         return $this->addSnippets($paths_list, $filters, $preAddCallback, $postAddCallback);
@@ -511,8 +531,12 @@  discard block
 block discarded – undo
511 531
         }
512 532
 
513 533
         $tempDir = tempnam(PCLZIP_TEMPORARY_DIR, 'merging');
514
-        if (file_exists($tempDir)) unlink($tempDir);
515
-        if (!mkdir($tempDir)) return 0;
534
+        if (file_exists($tempDir)) {
535
+         unlink($tempDir);
536
+        }
537
+        if (!mkdir($tempDir)) {
538
+         return 0;
539
+        }
516 540
 
517 541
         // go through archive content list and copy all files
518 542
         foreach ($a->getFileNames() as $filename) {
@@ -541,8 +565,11 @@  discard block
 block discarded – undo
541 565
 
542 566
         call_user_func(function ($directory) {
543 567
             foreach (glob($directory.'/*') as $f) {
544
-                if (is_dir($f)) call_user_func(__FUNCTION__, $f);
545
-                else unlink($f);
568
+                if (is_dir($f)) {
569
+                 call_user_func(__FUNCTION__, $f);
570
+                } else {
571
+                 unlink($f);
572
+                }
546 573
             }
547 574
         }, $tempDir);
548 575
 
@@ -567,18 +594,21 @@  discard block
 block discarded – undo
567 594
     {
568 595
         $filters = array();
569 596
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
570
-            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
571
-            $filters[] = function (&$key, &$value) use ($options) {
597
+            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
598
+                    $filters[] = function (&$key, &$value) use ($options) {
572 599
                 $key = str_replace($key, null, $key);
600
+        }
573 601
             };
574
-        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
575
-            $filters[] = function (&$key, &$value) {
602
+        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
603
+                    $filters[] = function (&$key, &$value) {
576 604
                 $key = basename($key);
605
+        }
577 606
             };
578
-        if (isset($options[PCLZIP_OPT_ADD_PATH]))
579
-            $filters[] = function (&$key, &$value) use ($options) {
607
+        if (isset($options[PCLZIP_OPT_ADD_PATH])) {
608
+                    $filters[] = function (&$key, &$value) use ($options) {
580 609
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/') . '/' .
581 610
                     ltrim($key, '/');
611
+        }
582 612
             };
583 613
         return $filters;
584 614
     }
@@ -593,11 +623,13 @@  discard block
 block discarded – undo
593 623
     {
594 624
         $preCallback = $postCallback = function () { return true; };
595 625
 
596
-        if (isset($options[$preCallbackConst]) && is_callable($options[$preCallbackConst]))
597
-            $preCallback = $options[$preCallbackConst];
626
+        if (isset($options[$preCallbackConst]) && is_callable($options[$preCallbackConst])) {
627
+                    $preCallback = $options[$preCallbackConst];
628
+        }
598 629
 
599
-        if (isset($options[$postCallbackConst]) && is_callable($options[$postCallbackConst]))
600
-            $postCallback = $options[$postCallbackConst];
630
+        if (isset($options[$postCallbackConst]) && is_callable($options[$postCallbackConst])) {
631
+                    $postCallback = $options[$postCallbackConst];
632
+        }
601 633
 
602 634
         return [$preCallback, $postCallback];
603 635
     }
@@ -610,7 +642,9 @@  discard block
 block discarded – undo
610 642
     {
611 643
         $keys = array_filter($options, function ($v) {return ($v%2) == 0;}, ARRAY_FILTER_USE_KEY);
612 644
         $values = array_filter($options, function ($v) {return ($v%2) == 1;}, ARRAY_FILTER_USE_KEY);
613
-        if (count($values) < count($keys)) $values[] = true;
645
+        if (count($values) < count($keys)) {
646
+         $values[] = true;
647
+        }
614 648
         return array_combine($keys, $values);
615 649
     }
616 650
 
@@ -653,9 +687,12 @@  discard block
 block discarded – undo
653 687
         $allowedIndexes = array();
654 688
         foreach ($indexes as $rule) {
655 689
             $parts = explode('-', $rule);
656
-            if (count($parts) == 1) $allowedIndexes[] = $rule;
657
-            else $allowedIndexes = array_merge(
690
+            if (count($parts) == 1) {
691
+             $allowedIndexes[] = $rule;
692
+            } else {
693
+             $allowedIndexes = array_merge(
658 694
                 range($parts[0], $parts[1]), $allowedIndexes);
695
+            }
659 696
         }
660 697
 
661 698
         return function ($key, $value, $index) use ($allowedIndexes) {
@@ -730,21 +767,26 @@  discard block
 block discarded – undo
730 767
     protected function createSelector(array $options)
731 768
     {
732 769
         // exact matching
733
-        if (isset($options[PCLZIP_OPT_BY_NAME]))
734
-            $selectFilter = $this->createByNameSelector($options[PCLZIP_OPT_BY_NAME]);
770
+        if (isset($options[PCLZIP_OPT_BY_NAME])) {
771
+                    $selectFilter = $this->createByNameSelector($options[PCLZIP_OPT_BY_NAME]);
772
+        }
735 773
         // <ereg> rule
736
-        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg'))
737
-            $selectFilter = $this->createByEregSelector($options[PCLZIP_OPT_BY_EREG]);
774
+        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg')) {
775
+                    $selectFilter = $this->createByEregSelector($options[PCLZIP_OPT_BY_EREG]);
776
+        }
738 777
         // <preg_match> rule
739
-        else if (isset($options[PCLZIP_OPT_BY_PREG]))
740
-            $selectFilter = $this->createByPregSelector($options[PCLZIP_OPT_BY_PREG]);
778
+        else if (isset($options[PCLZIP_OPT_BY_PREG])) {
779
+                    $selectFilter = $this->createByPregSelector($options[PCLZIP_OPT_BY_PREG]);
780
+        }
741 781
         // index rule
742
-        else if (isset($options[PCLZIP_OPT_BY_INDEX]))
743
-            $selectFilter = $this->createByIndexSelector($options[PCLZIP_OPT_BY_INDEX]);
782
+        else if (isset($options[PCLZIP_OPT_BY_INDEX])) {
783
+                    $selectFilter = $this->createByIndexSelector($options[PCLZIP_OPT_BY_INDEX]);
784
+        }
744 785
         // no rule
745
-        else
746
-            $selectFilter = function () {
786
+        else {
787
+                    $selectFilter = function () {
747 788
                 return self::SELECT_FILTER_PASS;
789
+        }
748 790
             };
749 791
         return $selectFilter;
750 792
     }
@@ -780,9 +822,9 @@  discard block
 block discarded – undo
780 822
     protected function buildComment(array $options, $currentComment)
781 823
     {
782 824
         $comment = null;
783
-        if (isset($options[PCLZIP_OPT_COMMENT]))
784
-            $comment = $options[PCLZIP_OPT_COMMENT];
785
-        else if (isset($options[PCLZIP_OPT_ADD_COMMENT])) {;
825
+        if (isset($options[PCLZIP_OPT_COMMENT])) {
826
+                    $comment = $options[PCLZIP_OPT_COMMENT];
827
+        } else if (isset($options[PCLZIP_OPT_ADD_COMMENT])) {;
786 828
             $comment = $currentComment . $options[PCLZIP_OPT_ADD_COMMENT];
787 829
         } else if (isset($options[PCLZIP_OPT_PREPEND_COMMENT])) {
788 830
             $comment = $options[PCLZIP_OPT_PREPEND_COMMENT] . $currentComment;
Please login to merge, or discard this patch.
src/ArchiveEntry.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,8 +46,9 @@
 block discarded – undo
46 46
         $this->compressedSize = $compressedSize;
47 47
         $this->uncompressedSize = $uncompressedSize;
48 48
         $this->modificationTime = $modificationTime;
49
-        if ($isCompressed === null)
50
-            $isCompressed = $uncompressedSize !== $compressedSize;
49
+        if ($isCompressed === null) {
50
+                    $isCompressed = $uncompressedSize !== $compressedSize;
51
+        }
51 52
         $this->isCompressed = $isCompressed;
52 53
         $this->comment = $comment;
53 54
         $this->crc32 = $crc32;
Please login to merge, or discard this patch.
src/Drivers/AlchemyZippy.php 1 patch
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -61,10 +61,11 @@  discard block
 block discarded – undo
61 61
 
62 62
     protected static function init()
63 63
     {
64
-        if (!class_exists('\Alchemy\Zippy\Zippy'))
65
-            static::$zippy = false;
66
-        else if (static::$zippy === null)
67
-            static::$zippy = Zippy::load();
64
+        if (!class_exists('\Alchemy\Zippy\Zippy')) {
65
+                    static::$zippy = false;
66
+        } else if (static::$zippy === null) {
67
+                    static::$zippy = Zippy::load();
68
+        }
68 69
     }
69 70
 
70 71
     /**
@@ -75,8 +76,9 @@  discard block
 block discarded – undo
75 76
     {
76 77
         static::init();
77 78
 
78
-        if (static::$zippy === false)
79
-            return [];
79
+        if (static::$zippy === false) {
80
+                    return [];
81
+        }
80 82
 
81 83
         switch ($format) {
82 84
             case Formats::TAR_BZIP:
@@ -212,8 +214,9 @@  discard block
 block discarded – undo
212 214
         $information = new ArchiveInformation();
213 215
 
214 216
         foreach ($this->archive->getMembers() as $member) {
215
-            if ($member->isDir())
216
-                continue;
217
+            if ($member->isDir()) {
218
+                            continue;
219
+            }
217 220
 
218 221
             $this->files[] = $information->files[] = str_replace('\\', '/', $member->getLocation());
219 222
             $this->members[str_replace('\\', '/', $member->getLocation())] = $member;
Please login to merge, or discard this patch.
src/Drivers/SevenZip.php 1 patch
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -120,12 +120,14 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public static function getInstallationInstruction()
122 122
     {
123
-        if (!class_exists('\Archive7z\Archive7z'))
124
-            return 'install library [gemorroj/archive7z]: `composer require gemorroj/archive7z`' . "\n"
123
+        if (!class_exists('\Archive7z\Archive7z')) {
124
+                    return 'install library [gemorroj/archive7z]: `composer require gemorroj/archive7z`' . "\n"
125 125
                 . ' and console program p7zip [7za]: `apt install p7zip-full` - depends on OS';
126
+        }
126 127
 
127
-        if (Archive7z::getBinaryVersion() === false)
128
-            return 'install console program p7zip [7za]: `apt install p7zip-full` - depends on OS';
128
+        if (Archive7z::getBinaryVersion() === false) {
129
+                    return 'install console program p7zip [7za]: `apt install p7zip-full` - depends on OS';
130
+        }
129 131
 
130 132
         return null;
131 133
     }
@@ -138,8 +140,9 @@  discard block
 block discarded – undo
138 140
         try {
139 141
             $this->format = $format;
140 142
             $this->sevenZip = new Archive7z($archiveFileName, null, null);
141
-            if ($password !== null)
142
-                $this->sevenZip->setPassword($password);
143
+            if ($password !== null) {
144
+                            $this->sevenZip->setPassword($password);
145
+            }
143 146
         } catch (\Archive7z\Exception $e) {
144 147
             throw new Exception('Could not open 7Zip archive: '.$e->getMessage(), $e->getCode(), $e);
145 148
         }
@@ -157,8 +160,9 @@  discard block
 block discarded – undo
157 160
                 continue;
158 161
             }
159 162
 
160
-            if (!isset($can_get_unix_path))
161
-                $can_get_unix_path = method_exists($entry, 'getUnixPath');
163
+            if (!isset($can_get_unix_path)) {
164
+                            $can_get_unix_path = method_exists($entry, 'getUnixPath');
165
+            }
162 166
 
163 167
             $information->files[] = $can_get_unix_path
164 168
                 ? $entry->getUnixPath()
@@ -176,8 +180,9 @@  discard block
 block discarded – undo
176 180
     {
177 181
         $files = [];
178 182
         foreach ($this->sevenZip->getEntries() as $entry) {
179
-            if ($entry->isDirectory())
180
-                continue;
183
+            if ($entry->isDirectory()) {
184
+                            continue;
185
+            }
181 186
             $files[] = $entry->getPath();
182 187
         }
183 188
         return $files;
@@ -329,8 +334,9 @@  discard block
 block discarded – undo
329 334
     public function addFileFromString($inArchiveName, $content)
330 335
     {
331 336
         $tmp_file = tempnam(sys_get_temp_dir(), 'ua');
332
-        if (!$tmp_file)
333
-            throw new ArchiveModificationException('Could not create temporarily file');
337
+        if (!$tmp_file) {
338
+                    throw new ArchiveModificationException('Could not create temporarily file');
339
+        }
334 340
 
335 341
         file_put_contents($tmp_file, $content);
336 342
         $this->sevenZip->addEntry($tmp_file, true);
@@ -380,8 +386,9 @@  discard block
 block discarded – undo
380 386
             $total_files = count($files);
381 387
 
382 388
             $seven_zip = new Archive7z($archiveFileName);
383
-            if ($password !== null)
384
-                $seven_zip->setPassword($password);
389
+            if ($password !== null) {
390
+                            $seven_zip->setPassword($password);
391
+            }
385 392
             $seven_zip->setCompressionLevel($compressionLevelMap[$compressionLevel]);
386 393
             foreach ($files as $localName => $filename) {
387 394
                 if ($filename !== null) {
Please login to merge, or discard this patch.
src/UnifiedArchive.php 1 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/Drivers/Zip.php 1 patch
Braces   +36 added lines, -24 removed lines patch added patch discarded remove patch
@@ -86,8 +86,9 @@  discard block
 block discarded – undo
86 86
     {
87 87
         parent::__construct($archiveFileName, $format);
88 88
         $this->open($archiveFileName);
89
-        if ($password !== null)
90
-            $this->zip->setPassword($password);
89
+        if ($password !== null) {
90
+                    $this->zip->setPassword($password);
91
+        }
91 92
     }
92 93
 
93 94
     /**
@@ -121,8 +122,9 @@  discard block
 block discarded – undo
121 122
         for ($i = 0; $i < $this->zip->numFiles; $i++) {
122 123
             $file = $this->zip->statIndex($i);
123 124
             // skip directories
124
-            if (in_array(substr($file['name'], -1), ['/', '\\'], true))
125
-                continue;
125
+            if (in_array(substr($file['name'], -1), ['/', '\\'], true)) {
126
+                            continue;
127
+            }
126 128
             $this->pureFilesNumber++;
127 129
             $information->files[$i] = $file['name'];
128 130
             $information->compressedFilesSize += $file['comp_size'];
@@ -157,8 +159,9 @@  discard block
 block discarded – undo
157 159
         for ($i = 0; $i < $this->zip->numFiles; $i++) {
158 160
             $file_name = $this->zip->getNameIndex($i);
159 161
             // skip directories
160
-            if (in_array(substr($file_name, -1), ['/', '\\'], true))
161
-                continue;
162
+            if (in_array(substr($file_name, -1), ['/', '\\'], true)) {
163
+                            continue;
164
+            }
162 165
             $files[] = $file_name;
163 166
         }
164 167
         return $files;
@@ -203,8 +206,9 @@  discard block
 block discarded – undo
203 206
     public function getFileContent($fileName)
204 207
     {
205 208
         $result = $this->zip->getFromName($fileName);
206
-        if ($result === false)
207
-            throw new Exception('Could not get file information: '.$result.'. May use password?');
209
+        if ($result === false) {
210
+                    throw new Exception('Could not get file information: '.$result.'. May use password?');
211
+        }
208 212
         return $result;
209 213
     }
210 214
 
@@ -225,8 +229,9 @@  discard block
 block discarded – undo
225 229
      */
226 230
     public function extractFiles($outputFolder, array $files)
227 231
     {
228
-        if ($this->zip->extractTo($outputFolder, $files) === false)
229
-            throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
232
+        if ($this->zip->extractTo($outputFolder, $files) === false) {
233
+                    throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
234
+        }
230 235
 
231 236
         return count($files);
232 237
     }
@@ -238,8 +243,9 @@  discard block
 block discarded – undo
238 243
      */
239 244
     public function extractArchive($outputFolder)
240 245
     {
241
-        if ($this->zip->extractTo($outputFolder) === false)
242
-            throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
246
+        if ($this->zip->extractTo($outputFolder) === false) {
247
+                    throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
248
+        }
243 249
 
244 250
         return $this->pureFilesNumber;
245 251
     }
@@ -254,8 +260,9 @@  discard block
 block discarded – undo
254 260
     {
255 261
         $count = 0;
256 262
         foreach ($files as $file) {
257
-            if ($this->zip->deleteName($file) === false)
258
-                throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
263
+            if ($this->zip->deleteName($file) === false) {
264
+                            throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
265
+            }
259 266
             $count++;
260 267
         }
261 268
 
@@ -278,11 +285,13 @@  discard block
 block discarded – undo
278 285
         $added_files = 0;
279 286
         foreach ($files as $localName => $fileName) {
280 287
             if (is_null($fileName)) {
281
-                if ($this->zip->addEmptyDir($localName) === false)
282
-                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
288
+                if ($this->zip->addEmptyDir($localName) === false) {
289
+                                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
290
+                }
283 291
             } else {
284
-                if ($this->zip->addFile($fileName, $localName) === false)
285
-                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
292
+                if ($this->zip->addFile($fileName, $localName) === false) {
293
+                                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
294
+                }
286 295
                 $added_files++;
287 296
             }
288 297
         }
@@ -335,8 +344,9 @@  discard block
 block discarded – undo
335 344
         $zip = new ZipArchive();
336 345
         $result = $zip->open($archiveFileName, ZipArchive::CREATE);
337 346
 
338
-        if ($result !== true)
339
-            throw new ArchiveCreationException('ZipArchive error: '.$result);
347
+        if ($result !== true) {
348
+                    throw new ArchiveCreationException('ZipArchive error: '.$result);
349
+        }
340 350
 
341 351
         $can_set_compression_level = method_exists($zip, 'setCompressionName');
342 352
         $can_encrypt = static::canEncrypt(Formats::ZIP);
@@ -354,11 +364,13 @@  discard block
 block discarded – undo
354 364
 
355 365
         foreach ($files as $localName => $fileName) {
356 366
             if ($fileName === null) {
357
-                if ($zip->addEmptyDir($localName) === false)
358
-                    throw new ArchiveCreationException('Could not archive directory "'.$localName.'": '.$zip->getStatusString(), $zip->status);
367
+                if ($zip->addEmptyDir($localName) === false) {
368
+                                    throw new ArchiveCreationException('Could not archive directory "'.$localName.'": '.$zip->getStatusString(), $zip->status);
369
+                }
359 370
             } else {
360
-                if ($zip->addFile($fileName, $localName) === false)
361
-                    throw new ArchiveCreationException('Could not archive file "'.$fileName.'": '.$zip->getStatusString(), $zip->status);
371
+                if ($zip->addFile($fileName, $localName) === false) {
372
+                                    throw new ArchiveCreationException('Could not archive file "'.$fileName.'": '.$zip->getStatusString(), $zip->status);
373
+                }
362 374
                 if ($can_set_compression_level) {
363 375
                     $zip->setCompressionName($localName, $compressionLevelMap[$compressionLevel]);
364 376
                 }
Please login to merge, or discard this patch.