Passed
Push — 1.1.x ( 3d3019...6d4a67 )
by f
02:55 queued 01:04
created
src/Archive7z.php 1 patch
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
      */
11 11
     public static function getBinaryVersion()
12 12
     {
13
-        if (method_exists(__CLASS__, 'makeBinary7z'))
14
-            try {
13
+        if (method_exists(__CLASS__, 'makeBinary7z')) {
14
+                    try {
15 15
                 $binary = static::makeBinary7z();
16
+        }
16 17
             } catch (\Exception $e) {
17 18
                 return false;
18
-            }
19
-        else {
19
+            } else {
20 20
             // some hack for gemorroj/archive7z 4.x version
21 21
             try {
22 22
                 $seven_zip = new self(null);
@@ -29,8 +29,9 @@  discard block
 block discarded – undo
29 29
 
30 30
         $process = new Process([str_replace('\\', '/', $binary)]);
31 31
         $result = $process->mustRun()->getOutput();
32
-        if (!preg_match('~7-Zip (\([a-z]\) )?(\[[\d]+\] )?(?<version>\d+\.\d+)~i', $result, $version))
33
-            return false;
32
+        if (!preg_match('~7-Zip (\([a-z]\) )?(\[[\d]+\] )?(?<version>\d+\.\d+)~i', $result, $version)) {
33
+                    return false;
34
+        }
34 35
 
35 36
         return $version['version'];
36 37
     }
Please login to merge, or discard this patch.
src/PclzipZipInterface.php 1 patch
Braces   +96 added lines, -56 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) {
@@ -338,8 +352,10 @@  discard block
 block discarded – undo
338 352
             // extract content
339 353
             else if ($anotherOutputFormat === false) {
340 354
                 // apply path filters
341
-                foreach ($filters as $filter) call_user_func($filter,
355
+                foreach ($filters as $filter) {
356
+                 call_user_func($filter,
342 357
                     $file_header->stored_filename, $file_header->filename);
358
+                }
343 359
                 // dir extraction process
344 360
                 if ($file_header->folder) {
345 361
                     // if dir doesn't exist
@@ -429,15 +445,19 @@  discard block
 block discarded – undo
429 445
      */
430 446
     public function add($content)
431 447
     {
432
-        if (is_array($content)) $paths_list = $content;
433
-        else $paths_list = explode(',', $content);
448
+        if (is_array($content)) {
449
+         $paths_list = $content;
450
+        } else {
451
+         $paths_list = explode(',', $content);
452
+        }
434 453
 
435 454
         $options = $this->makeOptionsFromArguments(func_get_args());
436 455
         $filters = $this->createFilters($options);
437 456
         list($preAddCallback, $postAddCallback) = $this->extractCallbacks($options, PCLZIP_CB_PRE_ADD, PCLZIP_CB_POST_ADD);
438 457
 
439
-        if (!empty($comment = $this->buildComment($options, $this->archive->getComment())))
440
-            $this->archive->setComment($comment);
458
+        if (!empty($comment = $this->buildComment($options, $this->archive->getComment()))) {
459
+                    $this->archive->setComment($comment);
460
+        }
441 461
 
442 462
         // scan filesystem for files list
443 463
         return $this->addSnippets($paths_list, $filters, $preAddCallback, $postAddCallback);
@@ -504,8 +524,12 @@  discard block
 block discarded – undo
504 524
         }
505 525
 
506 526
         $tempDir = tempnam(PCLZIP_TEMPORARY_DIR, 'merging');
507
-        if (file_exists($tempDir)) unlink($tempDir);
508
-        if (!mkdir($tempDir)) return 0;
527
+        if (file_exists($tempDir)) {
528
+         unlink($tempDir);
529
+        }
530
+        if (!mkdir($tempDir)) {
531
+         return 0;
532
+        }
509 533
 
510 534
         // go through archive content list and copy all files
511 535
         foreach ($a->getFileNames() as $filename) {
@@ -534,8 +558,11 @@  discard block
 block discarded – undo
534 558
 
535 559
         call_user_func(function ($directory) {
536 560
             foreach (glob($directory.'/*') as $f) {
537
-                if (is_dir($f)) call_user_func(__FUNCTION__, $f);
538
-                else unlink($f);
561
+                if (is_dir($f)) {
562
+                 call_user_func(__FUNCTION__, $f);
563
+                } else {
564
+                 unlink($f);
565
+                }
539 566
             }
540 567
         }, $tempDir);
541 568
 
@@ -560,18 +587,21 @@  discard block
 block discarded – undo
560 587
     {
561 588
         $filters = array();
562 589
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
563
-            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
564
-            $filters[] = function (&$key, &$value) use ($options) {
590
+            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
591
+                    $filters[] = function (&$key, &$value) use ($options) {
565 592
                 $key = str_replace($key, null, $key);
593
+        }
566 594
             };
567
-        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
568
-            $filters[] = function (&$key, &$value) {
595
+        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
596
+                    $filters[] = function (&$key, &$value) {
569 597
                 $key = basename($key);
598
+        }
570 599
             };
571
-        if (isset($options[PCLZIP_OPT_ADD_PATH]))
572
-            $filters[] = function (&$key, &$value) use ($options) {
600
+        if (isset($options[PCLZIP_OPT_ADD_PATH])) {
601
+                    $filters[] = function (&$key, &$value) use ($options) {
573 602
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/') . '/' .
574 603
                     ltrim($key, '/');
604
+        }
575 605
             };
576 606
         return $filters;
577 607
     }
@@ -586,11 +616,13 @@  discard block
 block discarded – undo
586 616
     {
587 617
         $preCallback = $postCallback = function () { return true; };
588 618
 
589
-        if (isset($options[$preCallbackConst]) && is_callable($options[$preCallbackConst]))
590
-            $preCallback = $options[$preCallbackConst];
619
+        if (isset($options[$preCallbackConst]) && is_callable($options[$preCallbackConst])) {
620
+                    $preCallback = $options[$preCallbackConst];
621
+        }
591 622
 
592
-        if (isset($options[$postCallbackConst]) && is_callable($options[$postCallbackConst]))
593
-            $postCallback = $options[$postCallbackConst];
623
+        if (isset($options[$postCallbackConst]) && is_callable($options[$postCallbackConst])) {
624
+                    $postCallback = $options[$postCallbackConst];
625
+        }
594 626
 
595 627
         return [$preCallback, $postCallback];
596 628
     }
@@ -646,9 +678,12 @@  discard block
 block discarded – undo
646 678
         $allowedIndexes = array();
647 679
         foreach ($indexes as $rule) {
648 680
             $parts = explode('-', $rule);
649
-            if (count($parts) == 1) $allowedIndexes[] = $rule;
650
-            else $allowedIndexes = array_merge(
681
+            if (count($parts) == 1) {
682
+             $allowedIndexes[] = $rule;
683
+            } else {
684
+             $allowedIndexes = array_merge(
651 685
                 range($parts[0], $parts[1]), $allowedIndexes);
686
+            }
652 687
         }
653 688
 
654 689
         return function ($key, $value, $index) use ($allowedIndexes) {
@@ -723,21 +758,26 @@  discard block
 block discarded – undo
723 758
     protected function createSelector(array $options)
724 759
     {
725 760
         // exact matching
726
-        if (isset($options[PCLZIP_OPT_BY_NAME]))
727
-            $selectFilter = $this->createByNameSelector($options[PCLZIP_OPT_BY_NAME]);
761
+        if (isset($options[PCLZIP_OPT_BY_NAME])) {
762
+                    $selectFilter = $this->createByNameSelector($options[PCLZIP_OPT_BY_NAME]);
763
+        }
728 764
         // <ereg> rule
729
-        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg'))
730
-            $selectFilter = $this->createByEregSelector($options[PCLZIP_OPT_BY_EREG]);
765
+        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg')) {
766
+                    $selectFilter = $this->createByEregSelector($options[PCLZIP_OPT_BY_EREG]);
767
+        }
731 768
         // <preg_match> rule
732
-        else if (isset($options[PCLZIP_OPT_BY_PREG]))
733
-            $selectFilter = $this->createByPregSelector($options[PCLZIP_OPT_BY_PREG]);
769
+        else if (isset($options[PCLZIP_OPT_BY_PREG])) {
770
+                    $selectFilter = $this->createByPregSelector($options[PCLZIP_OPT_BY_PREG]);
771
+        }
734 772
         // index rule
735
-        else if (isset($options[PCLZIP_OPT_BY_INDEX]))
736
-            $selectFilter = $this->createByIndexSelector($options[PCLZIP_OPT_BY_INDEX]);
773
+        else if (isset($options[PCLZIP_OPT_BY_INDEX])) {
774
+                    $selectFilter = $this->createByIndexSelector($options[PCLZIP_OPT_BY_INDEX]);
775
+        }
737 776
         // no rule
738
-        else
739
-            $selectFilter = function () {
777
+        else {
778
+                    $selectFilter = function () {
740 779
                 return self::SELECT_FILTER_PASS;
780
+        }
741 781
             };
742 782
         return $selectFilter;
743 783
     }
@@ -773,9 +813,9 @@  discard block
 block discarded – undo
773 813
     protected function buildComment(array $options, $currentComment)
774 814
     {
775 815
         $comment = null;
776
-        if (isset($options[PCLZIP_OPT_COMMENT]))
777
-            $comment = $options[PCLZIP_OPT_COMMENT];
778
-        else if (isset($options[PCLZIP_OPT_ADD_COMMENT])) {;
816
+        if (isset($options[PCLZIP_OPT_COMMENT])) {
817
+                    $comment = $options[PCLZIP_OPT_COMMENT];
818
+        } else if (isset($options[PCLZIP_OPT_ADD_COMMENT])) {;
779 819
             $comment = $currentComment . $options[PCLZIP_OPT_ADD_COMMENT];
780 820
         } else if (isset($options[PCLZIP_OPT_PREPEND_COMMENT])) {
781 821
             $comment = $options[PCLZIP_OPT_PREPEND_COMMENT] . $currentComment;
Please login to merge, or discard this patch.
src/Drivers/TarByPear.php 1 patch
Braces   +26 added lines, -18 removed lines patch added patch discarded remove patch
@@ -123,21 +123,24 @@  discard block
 block discarded – undo
123 123
                 break;
124 124
         }
125 125
 
126
-        if (isset($tar_aname))
127
-            $tar = new Archive_Tar($tar_aname, $compression);
128
-        else
129
-            $tar = new Archive_Tar($archiveFileName, $compression);
126
+        if (isset($tar_aname)) {
127
+                    $tar = new Archive_Tar($tar_aname, $compression);
128
+        } else {
129
+                    $tar = new Archive_Tar($archiveFileName, $compression);
130
+        }
130 131
 
131 132
         foreach ($files  as $localName => $filename) {
132 133
             $remove_dir = dirname($filename);
133 134
             $add_dir = dirname($localName);
134 135
 
135 136
             if (is_null($filename)) {
136
-                if ($tar->addString($localName, '') === false)
137
-                    throw new ArchiveCreationException('Error when adding directory '.$localName.' to archive');
137
+                if ($tar->addString($localName, '') === false) {
138
+                                    throw new ArchiveCreationException('Error when adding directory '.$localName.' to archive');
139
+                }
138 140
             } else {
139
-                if ($tar->addModify($filename, $add_dir, $remove_dir) === false)
140
-                    throw new ArchiveCreationException('Error when adding file '.$filename.' to archive');
141
+                if ($tar->addModify($filename, $add_dir, $remove_dir) === false) {
142
+                                    throw new ArchiveCreationException('Error when adding file '.$filename.' to archive');
143
+                }
141 144
             }
142 145
         }
143 146
         $tar = null;
@@ -194,8 +197,9 @@  discard block
 block discarded – undo
194 197
                 continue;
195 198
             }
196 199
             // skip directories
197
-            if ($file['typeflag'] == '5' || substr($file['filename'], -1) === '/')
198
-                continue;
200
+            if ($file['typeflag'] == '5' || substr($file['filename'], -1) === '/') {
201
+                            continue;
202
+            }
199 203
             $information->files[] = $file['filename'];
200 204
             $information->uncompressedFilesSize += $file['size'];
201 205
             $this->pearFilesIndex[$file['filename']] = $i;
@@ -240,14 +244,16 @@  discard block
 block discarded – undo
240 244
      */
241 245
     public function getFileData($fileName)
242 246
     {
243
-        if (!isset($this->pearFilesIndex[$fileName]))
244
-            throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
247
+        if (!isset($this->pearFilesIndex[$fileName])) {
248
+                    throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
249
+        }
245 250
 
246 251
         $index = $this->pearFilesIndex[$fileName];
247 252
 
248 253
         $files_list = $this->tar->listContent();
249
-        if (!isset($files_list[$index]))
250
-            throw new NonExistentArchiveFileException('File '.$fileName.' is not found in Tar archive');
254
+        if (!isset($files_list[$index])) {
255
+                    throw new NonExistentArchiveFileException('File '.$fileName.' is not found in Tar archive');
256
+        }
251 257
 
252 258
         $data = $files_list[$index];
253 259
         unset($files_list);
@@ -262,8 +268,9 @@  discard block
 block discarded – undo
262 268
      */
263 269
     public function getFileContent($fileName)
264 270
     {
265
-        if (!isset($this->pearFilesIndex[$fileName]))
266
-            throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
271
+        if (!isset($this->pearFilesIndex[$fileName])) {
272
+                    throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
273
+        }
267 274
 
268 275
         return $this->tar->extractInString($fileName);
269 276
     }
@@ -273,8 +280,9 @@  discard block
 block discarded – undo
273 280
      */
274 281
     public function getFileStream($fileName)
275 282
     {
276
-        if (!isset($this->pearFilesIndex[$fileName]))
277
-            throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
283
+        if (!isset($this->pearFilesIndex[$fileName])) {
284
+                    throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
285
+        }
278 286
 
279 287
         return self::wrapStringInStream($this->tar->extractInString($fileName));
280 288
     }
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
@@ -60,10 +60,11 @@  discard block
 block discarded – undo
60 60
 
61 61
     protected static function init()
62 62
     {
63
-        if (!class_exists('\Alchemy\Zippy\Zippy'))
64
-            static::$zippy = false;
65
-        else if (static::$zippy === null)
66
-            static::$zippy = Zippy::load();
63
+        if (!class_exists('\Alchemy\Zippy\Zippy')) {
64
+                    static::$zippy = false;
65
+        } else if (static::$zippy === null) {
66
+                    static::$zippy = Zippy::load();
67
+        }
67 68
     }
68 69
 
69 70
     /**
@@ -74,8 +75,9 @@  discard block
 block discarded – undo
74 75
     {
75 76
         static::init();
76 77
 
77
-        if (static::$zippy === false)
78
-            return false;
78
+        if (static::$zippy === false) {
79
+                    return false;
80
+        }
79 81
 
80 82
         switch ($format) {
81 83
             case Formats::TAR_BZIP:
@@ -189,8 +191,9 @@  discard block
 block discarded – undo
189 191
         $information = new ArchiveInformation();
190 192
 
191 193
         foreach ($this->archive->getMembers() as $member) {
192
-            if ($member->isDir())
193
-                continue;
194
+            if ($member->isDir()) {
195
+                            continue;
196
+            }
194 197
 
195 198
             $this->files[] = $information->files[] = str_replace('\\', '/', $member->getLocation());
196 199
             $this->members[str_replace('\\', '/', $member->getLocation())] = $member;
Please login to merge, or discard this patch.
src/Drivers/Rar.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -100,7 +100,9 @@  discard block
 block discarded – undo
100 100
     {
101 101
         $information = new ArchiveInformation();
102 102
         foreach ($this->rar->getEntries() as $i => $entry) {
103
-            if ($entry->isDirectory()) continue;
103
+            if ($entry->isDirectory()) {
104
+             continue;
105
+            }
104 106
             $information->files[] = $entry->getName();
105 107
             $information->compressedFilesSize += $entry->getPackedSize();
106 108
             $information->uncompressedFilesSize += $entry->getUnpackedSize();
@@ -115,7 +117,9 @@  discard block
 block discarded – undo
115 117
     {
116 118
         $files = [];
117 119
         foreach ($this->rar->getEntries() as $i => $entry) {
118
-            if ($entry->isDirectory()) continue;
120
+            if ($entry->isDirectory()) {
121
+             continue;
122
+            }
119 123
             $files[] = $entry->getName();
120 124
         }
121 125
         return $files;
@@ -151,7 +155,9 @@  discard block
 block discarded – undo
151 155
     public function getFileContent($fileName)
152 156
     {
153 157
         $entry = $this->rar->getEntry($fileName);
154
-        if ($entry->isDirectory()) return false;
158
+        if ($entry->isDirectory()) {
159
+         return false;
160
+        }
155 161
         return stream_get_contents($entry->getStream());
156 162
     }
157 163
 
@@ -163,7 +169,9 @@  discard block
 block discarded – undo
163 169
     public function getFileStream($fileName)
164 170
     {
165 171
         $entry = $this->rar->getEntry($fileName);
166
-        if ($entry->isDirectory()) return false;
172
+        if ($entry->isDirectory()) {
173
+         return false;
174
+        }
167 175
         return $entry->getStream();
168 176
     }
169 177
 
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
@@ -63,8 +63,9 @@  discard block
 block discarded – undo
63 63
     public function __construct($archiveFileName, $format, $password = null)
64 64
     {
65 65
         $this->open($archiveFileName);
66
-        if ($password !== null)
67
-            $this->zip->setPassword($password);
66
+        if ($password !== null) {
67
+                    $this->zip->setPassword($password);
68
+        }
68 69
     }
69 70
 
70 71
     /**
@@ -97,8 +98,9 @@  discard block
 block discarded – undo
97 98
         for ($i = 0; $i < $this->zip->numFiles; $i++) {
98 99
             $file = $this->zip->statIndex($i);
99 100
             // skip directories
100
-            if (in_array(substr($file['name'], -1), ['/', '\\'], true))
101
-                continue;
101
+            if (in_array(substr($file['name'], -1), ['/', '\\'], true)) {
102
+                            continue;
103
+            }
102 104
             $information->files[$i] = $file['name'];
103 105
             $information->compressedFilesSize += $file['comp_size'];
104 106
             $information->uncompressedFilesSize += $file['size'];
@@ -115,8 +117,9 @@  discard block
 block discarded – undo
115 117
         for ($i = 0; $i < $this->zip->numFiles; $i++) {
116 118
             $file_name = $this->zip->getNameIndex($i);
117 119
             // skip directories
118
-            if (in_array(substr($file_name, -1), ['/', '\\'], true))
119
-                continue;
120
+            if (in_array(substr($file_name, -1), ['/', '\\'], true)) {
121
+                            continue;
122
+            }
120 123
             $files[] = $file_name;
121 124
         }
122 125
         return $files;
@@ -153,8 +156,9 @@  discard block
 block discarded – undo
153 156
     public function getFileContent($fileName)
154 157
     {
155 158
         $result = $this->zip->getFromName($fileName);
156
-        if ($result === false)
157
-            throw new Exception('Could not get file information: '.$result.'. May use password?');
159
+        if ($result === false) {
160
+                    throw new Exception('Could not get file information: '.$result.'. May use password?');
161
+        }
158 162
         return $result;
159 163
     }
160 164
 
@@ -175,8 +179,9 @@  discard block
 block discarded – undo
175 179
      */
176 180
     public function extractFiles($outputFolder, array $files)
177 181
     {
178
-        if ($this->zip->extractTo($outputFolder, $files) === false)
179
-            throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
182
+        if ($this->zip->extractTo($outputFolder, $files) === false) {
183
+                    throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
184
+        }
180 185
 
181 186
         return count($files);
182 187
     }
@@ -188,8 +193,9 @@  discard block
 block discarded – undo
188 193
      */
189 194
     public function extractArchive($outputFolder)
190 195
     {
191
-        if ($this->zip->extractTo($outputFolder) === false)
192
-            throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
196
+        if ($this->zip->extractTo($outputFolder) === false) {
197
+                    throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
198
+        }
193 199
 
194 200
         return $this->zip->numFiles;
195 201
     }
@@ -204,8 +210,9 @@  discard block
 block discarded – undo
204 210
     {
205 211
         $count = 0;
206 212
         foreach ($files as $file) {
207
-            if ($this->zip->deleteName($file) === false)
208
-                throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
213
+            if ($this->zip->deleteName($file) === false) {
214
+                            throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
215
+            }
209 216
             $count++;
210 217
         }
211 218
 
@@ -228,11 +235,13 @@  discard block
 block discarded – undo
228 235
         $added_files = 0;
229 236
         foreach ($files as $localName => $fileName) {
230 237
             if (is_null($fileName)) {
231
-                if ($this->zip->addEmptyDir($localName) === false)
232
-                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
238
+                if ($this->zip->addEmptyDir($localName) === false) {
239
+                                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
240
+                }
233 241
             } else {
234
-                if ($this->zip->addFile($fileName, $localName) === false)
235
-                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
242
+                if ($this->zip->addFile($fileName, $localName) === false) {
243
+                                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
244
+                }
236 245
                 $added_files++;
237 246
             }
238 247
         }
@@ -267,8 +276,9 @@  discard block
 block discarded – undo
267 276
         $zip = new ZipArchive();
268 277
         $result = $zip->open($archiveFileName, ZipArchive::CREATE);
269 278
 
270
-        if ($result !== true)
271
-            throw new ArchiveCreationException('ZipArchive error: '.$result);
279
+        if ($result !== true) {
280
+                    throw new ArchiveCreationException('ZipArchive error: '.$result);
281
+        }
272 282
 
273 283
         $can_set_compression_level = method_exists($zip, 'setCompressionName');
274 284
         $can_encrypt = method_exists($zip, 'setEncryptionName');
@@ -279,11 +289,13 @@  discard block
 block discarded – undo
279 289
 
280 290
         foreach ($files as $localName => $fileName) {
281 291
             if ($fileName === null) {
282
-                if ($zip->addEmptyDir($localName) === false)
283
-                    throw new ArchiveCreationException('Could not archive directory "'.$localName.'": '.$zip->getStatusString(), $zip->status);
292
+                if ($zip->addEmptyDir($localName) === false) {
293
+                                    throw new ArchiveCreationException('Could not archive directory "'.$localName.'": '.$zip->getStatusString(), $zip->status);
294
+                }
284 295
             } else {
285
-                if ($zip->addFile($fileName, $localName) === false)
286
-                    throw new ArchiveCreationException('Could not archive file "'.$fileName.'": '.$zip->getStatusString(), $zip->status);
296
+                if ($zip->addFile($fileName, $localName) === false) {
297
+                                    throw new ArchiveCreationException('Could not archive file "'.$fileName.'": '.$zip->getStatusString(), $zip->status);
298
+                }
287 299
                 if ($can_set_compression_level) {
288 300
                     $zip->setCompressionName($localName, $compressionLevelMap[$compressionLevel]);
289 301
                 }
Please login to merge, or discard this patch.
src/Drivers/SevenZip.php 1 patch
Braces   +24 added lines, -16 removed lines patch added patch discarded remove patch
@@ -97,11 +97,13 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public static function getInstallationInstruction()
99 99
     {
100
-        if (!class_exists('\Archive7z\Archive7z'))
101
-            return 'install library `gemorroj/archive7z` and console program p7zip (7za)';
100
+        if (!class_exists('\Archive7z\Archive7z')) {
101
+                    return 'install library `gemorroj/archive7z` and console program p7zip (7za)';
102
+        }
102 103
 
103
-        if (Archive7z::getBinaryVersion() === false)
104
-            return 'install console program p7zip (7za)';
104
+        if (Archive7z::getBinaryVersion() === false) {
105
+                    return 'install console program p7zip (7za)';
106
+        }
105 107
 
106 108
         return null;
107 109
     }
@@ -114,8 +116,9 @@  discard block
 block discarded – undo
114 116
         try {
115 117
             $this->format = $format;
116 118
             $this->sevenZip = new Archive7z($archiveFileName, null, null);
117
-            if ($password !== null)
118
-                $this->sevenZip->setPassword($password);
119
+            if ($password !== null) {
120
+                            $this->sevenZip->setPassword($password);
121
+            }
119 122
         } catch (\Archive7z\Exception $e) {
120 123
             throw new Exception('Could not open 7Zip archive: '.$e->getMessage(), $e->getCode(), $e);
121 124
         }
@@ -133,8 +136,9 @@  discard block
 block discarded – undo
133 136
                 continue;
134 137
             }
135 138
 
136
-            if (!isset($can_get_unix_path))
137
-                $can_get_unix_path = method_exists($entry, 'getUnixPath');
139
+            if (!isset($can_get_unix_path)) {
140
+                            $can_get_unix_path = method_exists($entry, 'getUnixPath');
141
+            }
138 142
 
139 143
             $information->files[] = $can_get_unix_path
140 144
                 ? $entry->getUnixPath()
@@ -152,8 +156,9 @@  discard block
 block discarded – undo
152 156
     {
153 157
         $files = [];
154 158
         foreach ($this->sevenZip->getEntries() as $entry) {
155
-            if ($entry->isDirectory())
156
-                continue;
159
+            if ($entry->isDirectory()) {
160
+                            continue;
161
+            }
157 162
             $files[] = $entry->getPath();
158 163
         }
159 164
         return $files;
@@ -294,8 +299,9 @@  discard block
 block discarded – undo
294 299
     public function addFileFromString($inArchiveName, $content)
295 300
     {
296 301
         $tmp_file = tempnam(sys_get_temp_dir(), 'ua');
297
-        if (!$tmp_file)
298
-            throw new ArchiveModificationException('Could not create temporarily file');
302
+        if (!$tmp_file) {
303
+                    throw new ArchiveModificationException('Could not create temporarily file');
304
+        }
299 305
 
300 306
         file_put_contents($tmp_file, $content);
301 307
         unset($content);
@@ -325,8 +331,9 @@  discard block
 block discarded – undo
325 331
 
326 332
         try {
327 333
             $seven_zip = new Archive7z($archiveFileName);
328
-            if ($password !== null)
329
-                $seven_zip->setPassword($password);
334
+            if ($password !== null) {
335
+                            $seven_zip->setPassword($password);
336
+            }
330 337
             $seven_zip->setCompressionLevel($compressionLevelMap[$compressionLevel]);
331 338
             foreach ($files as $localName => $filename) {
332 339
                 if ($filename !== null) {
@@ -355,8 +362,9 @@  discard block
 block discarded – undo
355 362
             Formats::TAR,
356 363
             Formats::LZMA,
357 364
             Formats::ZIP]
358
-        ))
359
-            return self::canRenameFiles();
365
+        )) {
366
+                    return self::canRenameFiles();
367
+        }
360 368
 
361 369
         return false;
362 370
     }
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
@@ -43,8 +43,9 @@
 block discarded – undo
43 43
         $this->compressedSize = $compressedSize;
44 44
         $this->uncompressedSize = $uncompressedSize;
45 45
         $this->modificationTime = $modificationTime;
46
-        if ($isCompressed === null)
47
-            $isCompressed = $uncompressedSize !== $compressedSize;
46
+        if ($isCompressed === null) {
47
+                    $isCompressed = $uncompressedSize !== $compressedSize;
48
+        }
48 49
         $this->isCompressed = $isCompressed;
49 50
         $this->comment = $comment;
50 51
     }
Please login to merge, or discard this patch.
src/CamApplication.php 1 patch
Braces   +54 added lines, -37 removed lines patch added patch discarded remove patch
@@ -15,12 +15,14 @@  discard block
 block discarded – undo
15 15
      */
16 16
     protected function open($file, $password = null)
17 17
     {
18
-        if (!UnifiedArchive::canOpen($file))
19
-            throw new Exception('Could not open archive '.$file.'. Try installing suggested packages or run `cam -f` to see formats support.');
18
+        if (!UnifiedArchive::canOpen($file)) {
19
+                    throw new Exception('Could not open archive '.$file.'. Try installing suggested packages or run `cam -f` to see formats support.');
20
+        }
20 21
 
21 22
         $archive = UnifiedArchive::open($file, $password);
22
-        if ($archive === null)
23
-            throw new Exception('Could not open archive '.$file);
23
+        if ($archive === null) {
24
+                    throw new Exception('Could not open archive '.$file);
25
+        }
24 26
 
25 27
         return $archive;
26 28
     }
@@ -141,17 +143,18 @@  discard block
 block discarded – undo
141 143
      */
142 144
     public function formatDate($unixtime)
143 145
     {
144
-        if (strtotime('today') < $unixtime)
145
-            return 'Today, '.date('G:m', $unixtime);
146
-        else if (strtotime('yesterday') < $unixtime)
147
-            return 'Yesterday, '.date('G:m', $unixtime);
148
-        else {
146
+        if (strtotime('today') < $unixtime) {
147
+                    return 'Today, '.date('G:m', $unixtime);
148
+        } else if (strtotime('yesterday') < $unixtime) {
149
+                    return 'Yesterday, '.date('G:m', $unixtime);
150
+        } else {
149 151
             $datetime = new \DateTime();
150 152
             $datetime->setTimestamp($unixtime);
151
-            if ($datetime->format('Y') == date('Y'))
152
-                return $datetime->format('d M, G:m');
153
-            else
154
-                return $datetime->format('d M Y, G:m');
153
+            if ($datetime->format('Y') == date('Y')) {
154
+                            return $datetime->format('d M, G:m');
155
+            } else {
156
+                            return $datetime->format('d M Y, G:m');
157
+            }
155 158
         }
156 159
     }
157 160
 
@@ -181,25 +184,36 @@  discard block
 block discarded – undo
181 184
         $archive = $this->open($args['ARCHIVE'], isset($args['--password']) ? $args['--password'] : null);
182 185
         $output = getcwd();
183 186
         if (isset($args['--output'])) {
184
-            if (!is_dir($args['--output']))
185
-                mkdir($args['--output']);
187
+            if (!is_dir($args['--output'])) {
188
+                            mkdir($args['--output']);
189
+            }
186 190
             $output = realpath($args['--output']);
187 191
         }
188 192
 
189 193
         if (empty($args['FILES_IN_ARCHIVE']) || $args['FILES_IN_ARCHIVE'] == array('/') || $args['FILES_IN_ARCHIVE'] == array('*')) {
190 194
             $result = $archive->extractFiles($output);
191
-            if ($result === false) echo 'Error occured'.PHP_EOL;
192
-            else echo 'Extracted '.$result.' file(s) to '.$output.PHP_EOL;
195
+            if ($result === false) {
196
+             echo 'Error occured'.PHP_EOL;
197
+            } else {
198
+             echo 'Extracted '.$result.' file(s) to '.$output.PHP_EOL;
199
+            }
193 200
         } else {
194 201
             $extracted = 0;
195 202
             $errored = [];
196 203
             foreach ($args['FILES_IN_ARCHIVE'] as $file) {
197 204
                 $result = $archive->extractFiles($output, $file);
198
-                if ($result === false) $errored[] = $file;
199
-                else $extracted += $result;
205
+                if ($result === false) {
206
+                 $errored[] = $file;
207
+                } else {
208
+                 $extracted += $result;
209
+                }
210
+            }
211
+            if (!empty($errored)) {
212
+             echo 'Errored: '.implode(', ', $errored).PHP_EOL;
213
+            }
214
+            if ($extracted > 0) {
215
+             echo 'Exctracted '.$extracted.' file(s) to '.$output.PHP_EOL;
200 216
             }
201
-            if (!empty($errored)) echo 'Errored: '.implode(', ', $errored).PHP_EOL;
202
-            if ($extracted > 0) echo 'Exctracted '.$extracted.' file(s) to '.$output.PHP_EOL;
203 217
         }
204 218
     }
205 219
 
@@ -258,8 +272,9 @@  discard block
 block discarded – undo
258 272
                 echo 'File '.$file.' is NOT in archive'.PHP_EOL;
259 273
                 continue;
260 274
             }
261
-            if ($archive->deleteFiles($file) === false)
262
-                echo 'Error file '.$file.PHP_EOL;
275
+            if ($archive->deleteFiles($file) === false) {
276
+                            echo 'Error file '.$file.PHP_EOL;
277
+            }
263 278
         }
264 279
     }
265 280
 
@@ -272,10 +287,11 @@  discard block
 block discarded – undo
272 287
     {
273 288
         $archive = $this->open($args['ARCHIVE']);
274 289
         $added_files = $archive->addFiles($args['FILES_ON_DISK']);
275
-        if ($added_files === false)
276
-            echo 'Error'.PHP_EOL;
277
-        else
278
-            echo 'Added '.$added_files.' file(s)'.PHP_EOL;
290
+        if ($added_files === false) {
291
+                    echo 'Error'.PHP_EOL;
292
+        } else {
293
+                    echo 'Added '.$added_files.' file(s)'.PHP_EOL;
294
+        }
279 295
     }
280 296
 
281 297
     /**
@@ -293,9 +309,9 @@  discard block
 block discarded – undo
293 309
         $len = strlen($content);
294 310
 
295 311
         $added_files = $archive->addFileFromString($args['FILE_IN_ARCHIVE'], $content);
296
-        if ($added_files === false)
297
-            echo 'Error'.PHP_EOL;
298
-        else {
312
+        if ($added_files === false) {
313
+                    echo 'Error'.PHP_EOL;
314
+        } else {
299 315
             $size = $this->formatSize($len);
300 316
             echo sprintf('Added %s(%1.1f%s) file to %s',
301 317
                     $args['FILE_IN_ARCHIVE'], $size[0], $size[1], $args['ARCHIVE']) . PHP_EOL;
@@ -310,9 +326,9 @@  discard block
 block discarded – undo
310 326
     {
311 327
         $password = isset($args['--password']) ? $args['--password'] : null;
312 328
         if (file_exists($args['ARCHIVE'])) {
313
-            if (is_dir($args['ARCHIVE']))
314
-                echo $args['ARCHIVE'].' is a directory!'.PHP_EOL;
315
-            else {
329
+            if (is_dir($args['ARCHIVE'])) {
330
+                            echo $args['ARCHIVE'].' is a directory!'.PHP_EOL;
331
+            } else {
316 332
                 echo 'File '.$args['ARCHIVE'].' already exists!'.PHP_EOL;
317 333
             }
318 334
         } else {
@@ -329,10 +345,11 @@  discard block
 block discarded – undo
329 345
             }
330 346
 
331 347
             $archived_files = UnifiedArchive::archiveFiles($files, $args['ARCHIVE'], BasicDriver::COMPRESSION_AVERAGE, $password);
332
-            if ($archived_files === false)
333
-                echo 'Error'.PHP_EOL;
334
-            else
335
-                echo 'Created archive ' . $args['ARCHIVE'] . ' with ' . $archived_files . ' file(s) of total size ' . implode('', $this->formatSize(filesize($args['ARCHIVE']))) . PHP_EOL;
348
+            if ($archived_files === false) {
349
+                            echo 'Error'.PHP_EOL;
350
+            } else {
351
+                            echo 'Created archive ' . $args['ARCHIVE'] . ' with ' . $archived_files . ' file(s) of total size ' . implode('', $this->formatSize(filesize($args['ARCHIVE']))) . PHP_EOL;
352
+            }
336 353
         }
337 354
     }
338 355
 
Please login to merge, or discard this patch.