@@ -532,7 +532,7 @@ discard block  | 
                                                    ||
| 532 | 532 | }  | 
                                                        
| 533 | 533 | }  | 
                                                        
| 534 | 534 | |
| 535 | -        call_user_func(function ($directory) { | 
                                                        |
| 535 | +        call_user_func(function($directory) { | 
                                                        |
| 536 | 536 |              foreach (glob($directory.'/*') as $f) { | 
                                                        
| 537 | 537 | if (is_dir($f)) call_user_func(__FUNCTION__, $f);  | 
                                                        
| 538 | 538 | else unlink($f);  | 
                                                        
@@ -561,16 +561,16 @@ discard block  | 
                                                    ||
| 561 | 561 | $filters = array();  | 
                                                        
| 562 | 562 | if (isset($options[PCLZIP_OPT_REMOVE_PATH])  | 
                                                        
| 563 | 563 | && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))  | 
                                                        
| 564 | -            $filters[] = function (&$key, &$value) use ($options) { | 
                                                        |
| 564 | +            $filters[] = function(&$key, &$value) use ($options) { | 
                                                        |
| 565 | 565 | $key = str_replace($key, null, $key);  | 
                                                        
| 566 | 566 | };  | 
                                                        
| 567 | 567 | if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))  | 
                                                        
| 568 | -            $filters[] = function (&$key, &$value) { | 
                                                        |
| 568 | +            $filters[] = function(&$key, &$value) { | 
                                                        |
| 569 | 569 | $key = basename($key);  | 
                                                        
| 570 | 570 | };  | 
                                                        
| 571 | 571 | if (isset($options[PCLZIP_OPT_ADD_PATH]))  | 
                                                        
| 572 | -            $filters[] = function (&$key, &$value) use ($options) { | 
                                                        |
| 573 | - $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/') . '/' .  | 
                                                        |
| 572 | +            $filters[] = function(&$key, &$value) use ($options) { | 
                                                        |
| 573 | + $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.  | 
                                                        |
| 574 | 574 | ltrim($key, '/');  | 
                                                        
| 575 | 575 | };  | 
                                                        
| 576 | 576 | return $filters;  | 
                                                        
@@ -584,7 +584,7 @@ discard block  | 
                                                    ||
| 584 | 584 | */  | 
                                                        
| 585 | 585 | private function extractCallbacks(array $options, $preCallbackConst, $postCallbackConst)  | 
                                                        
| 586 | 586 |      { | 
                                                        
| 587 | -        $preCallback = $postCallback = function () { return true; }; | 
                                                        |
| 587 | +        $preCallback = $postCallback = function() { return true; }; | 
                                                        |
| 588 | 588 | |
| 589 | 589 | if (isset($options[$preCallbackConst]) && is_callable($options[$preCallbackConst]))  | 
                                                        
| 590 | 590 | $preCallback = $options[$preCallbackConst];  | 
                                                        
@@ -602,8 +602,8 @@ discard block  | 
                                                    ||
| 602 | 602 | private function makeKeyValueArrayFromList(array $options)  | 
                                                        
| 603 | 603 |      { | 
                                                        
| 604 | 604 | return array_combine(  | 
                                                        
| 605 | -            array_filter($options, function ($v) {return (bool) $v&2;}), | 
                                                        |
| 606 | -            array_filter($options, function ($v) {return (bool) ($v-1)&2;}) | 
                                                        |
| 605 | +            array_filter($options, function($v) {return (bool) $v & 2; }), | 
                                                        |
| 606 | +            array_filter($options, function($v) {return (bool) ($v - 1) & 2; }) | 
                                                        |
| 607 | 607 | );  | 
                                                        
| 608 | 608 | }  | 
                                                        
| 609 | 609 | |
@@ -651,7 +651,7 @@ discard block  | 
                                                    ||
| 651 | 651 | range($parts[0], $parts[1]), $allowedIndexes);  | 
                                                        
| 652 | 652 | }  | 
                                                        
| 653 | 653 | |
| 654 | -        return function ($key, $value, $index) use ($allowedIndexes) { | 
                                                        |
| 654 | +        return function($key, $value, $index) use ($allowedIndexes) { | 
                                                        |
| 655 | 655 | return in_array($index, $allowedIndexes)  | 
                                                        
| 656 | 656 | ? self::SELECT_FILTER_PASS  | 
                                                        
| 657 | 657 | : self::SELECT_FILTER_REFUSE;  | 
                                                        
@@ -668,7 +668,7 @@ discard block  | 
                                                    ||
| 668 | 668 | ? $names  | 
                                                        
| 669 | 669 |              : explode(',', $names); | 
                                                        
| 670 | 670 | |
| 671 | -        return function ($key, $value) use ($allowedNames) { | 
                                                        |
| 671 | +        return function($key, $value) use ($allowedNames) { | 
                                                        |
| 672 | 672 |              foreach ($allowedNames as $name) { | 
                                                        
| 673 | 673 | // select directory with nested files  | 
                                                        
| 674 | 674 |                  if (in_array(substr($name, -1), ['/', '\\'])) { | 
                                                        
@@ -696,7 +696,7 @@ discard block  | 
                                                    ||
| 696 | 696 | */  | 
                                                        
| 697 | 697 | protected function createByEregSelector($regex)  | 
                                                        
| 698 | 698 |      { | 
                                                        
| 699 | -        return function ($key, $value) use ($regex) { | 
                                                        |
| 699 | +        return function($key, $value) use ($regex) { | 
                                                        |
| 700 | 700 | return (ereg($regex, $key) !== false)  | 
                                                        
| 701 | 701 | ? self::SELECT_FILTER_PASS  | 
                                                        
| 702 | 702 | : self::SELECT_FILTER_REFUSE;  | 
                                                        
@@ -709,7 +709,7 @@ discard block  | 
                                                    ||
| 709 | 709 | */  | 
                                                        
| 710 | 710 | protected function createByPregSelector($regex)  | 
                                                        
| 711 | 711 |      { | 
                                                        
| 712 | -        return function ($key, $value) use ($regex) { | 
                                                        |
| 712 | +        return function($key, $value) use ($regex) { | 
                                                        |
| 713 | 713 | return preg_match($regex, $key)  | 
                                                        
| 714 | 714 | ? self::SELECT_FILTER_PASS  | 
                                                        
| 715 | 715 | : self::SELECT_FILTER_REFUSE;  | 
                                                        
@@ -736,7 +736,7 @@ discard block  | 
                                                    ||
| 736 | 736 | $selectFilter = $this->createByIndexSelector($options[PCLZIP_OPT_BY_INDEX]);  | 
                                                        
| 737 | 737 | // no rule  | 
                                                        
| 738 | 738 | else  | 
                                                        
| 739 | -            $selectFilter = function () { | 
                                                        |
| 739 | +            $selectFilter = function() { | 
                                                        |
| 740 | 740 | return self::SELECT_FILTER_PASS;  | 
                                                        
| 741 | 741 | };  | 
                                                        
| 742 | 742 | return $selectFilter;  | 
                                                        
@@ -776,9 +776,9 @@ discard block  | 
                                                    ||
| 776 | 776 | if (isset($options[PCLZIP_OPT_COMMENT]))  | 
                                                        
| 777 | 777 | $comment = $options[PCLZIP_OPT_COMMENT];  | 
                                                        
| 778 | 778 |          else if (isset($options[PCLZIP_OPT_ADD_COMMENT])) {; | 
                                                        
| 779 | - $comment = $currentComment . $options[PCLZIP_OPT_ADD_COMMENT];  | 
                                                        |
| 779 | + $comment = $currentComment.$options[PCLZIP_OPT_ADD_COMMENT];  | 
                                                        |
| 780 | 780 |          } else if (isset($options[PCLZIP_OPT_PREPEND_COMMENT])) { | 
                                                        
| 781 | - $comment = $options[PCLZIP_OPT_PREPEND_COMMENT] . $currentComment;  | 
                                                        |
| 781 | + $comment = $options[PCLZIP_OPT_PREPEND_COMMENT].$currentComment;  | 
                                                        |
| 782 | 782 | }  | 
                                                        
| 783 | 783 | return $comment;  | 
                                                        
| 784 | 784 | }  | 
                                                        
@@ -137,8 +137,11 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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;  | 
                                                        
@@ -158,8 +158,9 @@ discard block  | 
                                                    ||
| 158 | 158 | // by file content  | 
                                                        
| 159 | 159 |          if ($contentCheck) { | 
                                                        
| 160 | 160 | $mime_type = mime_content_type($fileName);  | 
                                                        
| 161 | - if (isset(static::$mimeTypes[$mime_type]))  | 
                                                        |
| 162 | - return static::$mimeTypes[$mime_type];  | 
                                                        |
| 161 | +            if (isset(static::$mimeTypes[$mime_type])) { | 
                                                        |
| 162 | + return static::$mimeTypes[$mime_type];  | 
                                                        |
| 163 | + }  | 
                                                        |
| 163 | 164 | }  | 
                                                        
| 164 | 165 | |
| 165 | 166 | return false;  | 
                                                        
@@ -251,12 +252,14 @@ discard block  | 
                                                    ||
| 251 | 252 |      { | 
                                                        
| 252 | 253 | |
| 253 | 254 | static::retrieveAllFormats();  | 
                                                        
| 254 | - if (!static::canOpen($format))  | 
                                                        |
| 255 | - return false;  | 
                                                        |
| 255 | +        if (!static::canOpen($format)) { | 
                                                        |
| 256 | + return false;  | 
                                                        |
| 257 | + }  | 
                                                        |
| 256 | 258 | |
| 257 | 259 |          foreach (static::$formatsSupport[$format] as $driver) { | 
                                                        
| 258 | - if ($driver::$function($format))  | 
                                                        |
| 259 | - return true;  | 
                                                        |
| 260 | +            if ($driver::$function($format)) { | 
                                                        |
| 261 | + return true;  | 
                                                        |
| 262 | + }  | 
                                                        |
| 260 | 263 | }  | 
                                                        
| 261 | 264 | |
| 262 | 265 | return false;  | 
                                                        
@@ -271,15 +274,18 @@ discard block  | 
                                                    ||
| 271 | 274 |      { | 
                                                        
| 272 | 275 | static::retrieveAllFormats();  | 
                                                        
| 273 | 276 | |
| 274 | - if (!static::canOpen($format))  | 
                                                        |
| 275 | -            throw new UnsupportedArchiveException('Unsupported archive type: '.$format.' of archive '); | 
                                                        |
| 277 | +        if (!static::canOpen($format)) { | 
                                                        |
| 278 | +                    throw new UnsupportedArchiveException('Unsupported archive type: '.$format.' of archive '); | 
                                                        |
| 279 | + }  | 
                                                        |
| 276 | 280 | |
| 277 | - if (!$createAbility)  | 
                                                        |
| 278 | - return current(static::$formatsSupport[$format]);  | 
                                                        |
| 281 | +        if (!$createAbility) { | 
                                                        |
| 282 | + return current(static::$formatsSupport[$format]);  | 
                                                        |
| 283 | + }  | 
                                                        |
| 279 | 284 | |
| 280 | 285 |          foreach (static::$formatsSupport[$format] as $driver) { | 
                                                        
| 281 | - if ($driver::canCreateArchive($format))  | 
                                                        |
| 282 | - return $driver;  | 
                                                        |
| 286 | +            if ($driver::canCreateArchive($format)) { | 
                                                        |
| 287 | + return $driver;  | 
                                                        |
| 288 | + }  | 
                                                        |
| 283 | 289 | }  | 
                                                        
| 284 | 290 | return false;  | 
                                                        
| 285 | 291 | }  | 
                                                        
@@ -245,13 +245,15 @@ discard block  | 
                                                    ||
| 245 | 245 | */  | 
                                                        
| 246 | 246 | public function getFileNames($filter = null)  | 
                                                        
| 247 | 247 |      { | 
                                                        
| 248 | - if ($filter === null)  | 
                                                        |
| 249 | - return $this->files;  | 
                                                        |
| 248 | +        if ($filter === null) { | 
                                                        |
| 249 | + return $this->files;  | 
                                                        |
| 250 | + }  | 
                                                        |
| 250 | 251 | |
| 251 | 252 | $result = [];  | 
                                                        
| 252 | 253 |          foreach ($this->files as $file) { | 
                                                        
| 253 | - if (fnmatch($filter, $file))  | 
                                                        |
| 254 | - $result[] = $file;  | 
                                                        |
| 254 | +            if (fnmatch($filter, $file)) { | 
                                                        |
| 255 | + $result[] = $file;  | 
                                                        |
| 256 | + }  | 
                                                        |
| 255 | 257 | }  | 
                                                        
| 256 | 258 | return $result;  | 
                                                        
| 257 | 259 | }  | 
                                                        
@@ -378,8 +380,9 @@ discard block  | 
                                                    ||
| 378 | 380 |      { | 
                                                        
| 379 | 381 | $files_list = static::createFilesList($fileOrFiles);  | 
                                                        
| 380 | 382 | |
| 381 | - if (empty($files_list))  | 
                                                        |
| 382 | -            throw new EmptyFileListException('Files list is empty!'); | 
                                                        |
| 383 | +        if (empty($files_list)) { | 
                                                        |
| 384 | +                    throw new EmptyFileListException('Files list is empty!'); | 
                                                        |
| 385 | + }  | 
                                                        |
| 383 | 386 | |
| 384 | 387 | $result = $this->archive->addFiles($files_list);  | 
                                                        
| 385 | 388 | $this->scanArchive();  | 
                                                        
@@ -398,8 +401,9 @@ discard block  | 
                                                    ||
| 398 | 401 | */  | 
                                                        
| 399 | 402 | public function addFile($file, $inArchiveName = null)  | 
                                                        
| 400 | 403 |      { | 
                                                        
| 401 | - if (!is_file($file))  | 
                                                        |
| 402 | - throw new InvalidArgumentException($file.' is not a valid file to add in archive');  | 
                                                        |
| 404 | +        if (!is_file($file)) { | 
                                                        |
| 405 | + throw new InvalidArgumentException($file.' is not a valid file to add in archive');  | 
                                                        |
| 406 | + }  | 
                                                        |
| 403 | 407 | |
| 404 | 408 | return ($inArchiveName !== null  | 
                                                        
| 405 | 409 | ? $this->addFiles([$inArchiveName => $file])  | 
                                                        
@@ -432,8 +436,9 @@ discard block  | 
                                                    ||
| 432 | 436 | */  | 
                                                        
| 433 | 437 | public function addDirectory($directory, $inArchivePath = null)  | 
                                                        
| 434 | 438 |      { | 
                                                        
| 435 | - if (!is_dir($directory) || !is_readable($directory))  | 
                                                        |
| 436 | - throw new InvalidArgumentException($directory.' is not a valid directory to add in archive');  | 
                                                        |
| 439 | +        if (!is_dir($directory) || !is_readable($directory)) { | 
                                                        |
| 440 | + throw new InvalidArgumentException($directory.' is not a valid directory to add in archive');  | 
                                                        |
| 441 | + }  | 
                                                        |
| 437 | 442 | |
| 438 | 443 | return ($inArchivePath !== null  | 
                                                        
| 439 | 444 | ? $this->addFiles([$inArchivePath => $directory])  | 
                                                        
@@ -457,13 +462,15 @@ discard block  | 
                                                    ||
| 457 | 462 |      { | 
                                                        
| 458 | 463 | $archiveType = Formats::detectArchiveFormat($archiveName, false);  | 
                                                        
| 459 | 464 | |
| 460 | - if ($archiveType === false)  | 
                                                        |
| 461 | -            throw new UnsupportedArchiveException('Could not detect archive type for name "'.$archiveName.'"'); | 
                                                        |
| 465 | +        if ($archiveType === false) { | 
                                                        |
| 466 | +                    throw new UnsupportedArchiveException('Could not detect archive type for name "'.$archiveName.'"'); | 
                                                        |
| 467 | + }  | 
                                                        |
| 462 | 468 | |
| 463 | 469 | $files_list = static::createFilesList($fileOrFiles);  | 
                                                        
| 464 | 470 | |
| 465 | - if (empty($files_list))  | 
                                                        |
| 466 | -            throw new EmptyFileListException('Files list is empty!'); | 
                                                        |
| 471 | +        if (empty($files_list)) { | 
                                                        |
| 472 | +                    throw new EmptyFileListException('Files list is empty!'); | 
                                                        |
| 473 | + }  | 
                                                        |
| 467 | 474 | |
| 468 | 475 | $totalSize = 0;  | 
                                                        
| 469 | 476 |          foreach ($files_list as $fn) { | 
                                                        
@@ -508,16 +515,19 @@ discard block  | 
                                                    ||
| 508 | 515 | */  | 
                                                        
| 509 | 516 | public static function archiveFiles($fileOrFiles, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)  | 
                                                        
| 510 | 517 |      { | 
                                                        
| 511 | - if (file_exists($archiveName))  | 
                                                        |
| 512 | -            throw new FileAlreadyExistsException('Archive '.$archiveName.' already exists!'); | 
                                                        |
| 518 | +        if (file_exists($archiveName)) { | 
                                                        |
| 519 | +                    throw new FileAlreadyExistsException('Archive '.$archiveName.' already exists!'); | 
                                                        |
| 520 | + }  | 
                                                        |
| 513 | 521 | |
| 514 | 522 | $info = static::prepareForArchiving($fileOrFiles, $archiveName);  | 
                                                        
| 515 | 523 | |
| 516 | - if (!Formats::canCreate($info['type']))  | 
                                                        |
| 517 | -            throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '.$archiveName); | 
                                                        |
| 524 | +        if (!Formats::canCreate($info['type'])) { | 
                                                        |
| 525 | +                    throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '.$archiveName); | 
                                                        |
| 526 | + }  | 
                                                        |
| 518 | 527 | |
| 519 | - if ($password !== null && !Formats::canEncrypt($info['type']))  | 
                                                        |
| 520 | -            throw new UnsupportedOperationException('Archive type '.$info['type'].' can not be encrypted'); | 
                                                        |
| 528 | +        if ($password !== null && !Formats::canEncrypt($info['type'])) { | 
                                                        |
| 529 | +                    throw new UnsupportedOperationException('Archive type '.$info['type'].' can not be encrypted'); | 
                                                        |
| 530 | + }  | 
                                                        |
| 521 | 531 | |
| 522 | 532 | /** @var BasicDriver $handler_class */  | 
                                                        
| 523 | 533 | $driver = Formats::getFormatDriver($info['type'], true);  | 
                                                        
@@ -558,8 +568,9 @@ discard block  | 
                                                    ||
| 558 | 568 | */  | 
                                                        
| 559 | 569 | public static function archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)  | 
                                                        
| 560 | 570 |      { | 
                                                        
| 561 | - if (!is_dir($directory) || !is_readable($directory))  | 
                                                        |
| 562 | - throw new InvalidArgumentException($directory.' is not a valid directory to archive');  | 
                                                        |
| 571 | +        if (!is_dir($directory) || !is_readable($directory)) { | 
                                                        |
| 572 | + throw new InvalidArgumentException($directory.' is not a valid directory to archive');  | 
                                                        |
| 573 | + }  | 
                                                        |
| 563 | 574 | |
| 564 | 575 | return static::archiveFiles($directory, $archiveName, $compressionLevel, $password) > 0;  | 
                                                        
| 565 | 576 | }  | 
                                                        
@@ -594,26 +605,29 @@ discard block  | 
                                                    ||
| 594 | 605 | // passed an extended list  | 
                                                        
| 595 | 606 |          if (is_array($nodes)) { | 
                                                        
| 596 | 607 |              foreach ($nodes as $destination => $source) { | 
                                                        
| 597 | - if (is_numeric($destination))  | 
                                                        |
| 598 | - $destination = $source;  | 
                                                        |
| 608 | +                if (is_numeric($destination)) { | 
                                                        |
| 609 | + $destination = $source;  | 
                                                        |
| 610 | + }  | 
                                                        |
| 599 | 611 | |
| 600 | 612 | $destination = rtrim($destination, '/\\*');  | 
                                                        
| 601 | 613 | |
| 602 | 614 | // if is directory  | 
                                                        
| 603 | - if (is_dir($source))  | 
                                                        |
| 604 | - static::importFilesFromDir(rtrim($source, '/\\*').'/*',  | 
                                                        |
| 615 | +                if (is_dir($source)) { | 
                                                        |
| 616 | + static::importFilesFromDir(rtrim($source, '/\\*').'/*',  | 
                                                        |
| 605 | 617 | !empty($destination) ? $destination.'/' : null, true, $files);  | 
                                                        
| 606 | - else if (is_file($source))  | 
                                                        |
| 607 | - $files[$destination] = $source;  | 
                                                        |
| 618 | +                } else if (is_file($source)) { | 
                                                        |
| 619 | + $files[$destination] = $source;  | 
                                                        |
| 620 | + }  | 
                                                        |
| 608 | 621 | }  | 
                                                        
| 609 | 622 | |
| 610 | 623 |          } else if (is_string($nodes)) { // passed one file or directory | 
                                                        
| 611 | 624 | // if is directory  | 
                                                        
| 612 | - if (is_dir($nodes))  | 
                                                        |
| 613 | - static::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true,  | 
                                                        |
| 625 | +            if (is_dir($nodes)) { | 
                                                        |
| 626 | + static::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true,  | 
                                                        |
| 614 | 627 | $files);  | 
                                                        
| 615 | - else if (is_file($nodes))  | 
                                                        |
| 616 | - $files[basename($nodes)] = $nodes;  | 
                                                        |
| 628 | +            } else if (is_file($nodes)) { | 
                                                        |
| 629 | + $files[basename($nodes)] = $nodes;  | 
                                                        |
| 630 | + }  | 
                                                        |
| 617 | 631 | }  | 
                                                        
| 618 | 632 | |
| 619 | 633 | return $files;  | 
                                                        
@@ -630,8 +644,9 @@ discard block  | 
                                                    ||
| 630 | 644 | // $map[$destination] = rtrim($source, '/*');  | 
                                                        
| 631 | 645 | // do not map root archive folder  | 
                                                        
| 632 | 646 | |
| 633 | - if ($destination !== null)  | 
                                                        |
| 634 | - $map[$destination] = null;  | 
                                                        |
| 647 | +        if ($destination !== null) { | 
                                                        |
| 648 | + $map[$destination] = null;  | 
                                                        |
| 649 | + }  | 
                                                        |
| 635 | 650 | |
| 636 | 651 |          foreach (glob($source, GLOB_MARK) as $node) { | 
                                                        
| 637 | 652 |              if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) { | 
                                                        
@@ -43,8 +43,9 @@  | 
                                                    ||
| 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 | }  | 
                                                        
@@ -31,7 +31,7 @@ discard block  | 
                                                    ||
| 31 | 31 | public function checkFormats()  | 
                                                        
| 32 | 32 |      { | 
                                                        
| 33 | 33 | echo "format\topen\tstream\tcreate\tappend\tupdate\tencrypt\tdrivers".PHP_EOL;  | 
                                                        
| 34 | -        foreach(Formats::getFormatsReport() as $format => $config) { | 
                                                        |
| 34 | +        foreach (Formats::getFormatsReport() as $format => $config) { | 
                                                        |
| 35 | 35 | echo $format."\t"  | 
                                                        
| 36 | 36 | .($config['open'] ? '+' : '-')."\t"  | 
                                                        
| 37 | 37 | .($config['stream'] ? '+' : '-')."\t"  | 
                                                        
@@ -55,7 +55,7 @@ discard block  | 
                                                    ||
| 55 | 55 |              if (!empty($install)) { | 
                                                        
| 56 | 56 | $notInstalled[] = [$driverClass, $description, $install];  | 
                                                        
| 57 | 57 |              } else { | 
                                                        
| 58 | - echo ($i++) . '. ' . $driverClass . ' - ' . $description . PHP_EOL;  | 
                                                        |
| 58 | + echo ($i++).'. '.$driverClass.' - '.$description.PHP_EOL;  | 
                                                        |
| 59 | 59 | }  | 
                                                        
| 60 | 60 | }  | 
                                                        
| 61 | 61 | |
@@ -63,8 +63,8 @@ discard block  | 
                                                    ||
| 63 | 63 | echo PHP_EOL.'Not installed:'.PHP_EOL;  | 
                                                        
| 64 | 64 | $i = 1;  | 
                                                        
| 65 | 65 |              foreach ($notInstalled as $data) { | 
                                                        
| 66 | - echo ($i++) . '. ' . $data[0] . ' - ' . $data[1] . PHP_EOL  | 
                                                        |
| 67 | - . '- ' . $data[2] . PHP_EOL.PHP_EOL;  | 
                                                        |
| 66 | + echo ($i++).'. '.$data[0].' - '.$data[1].PHP_EOL  | 
                                                        |
| 67 | + . '- '.$data[2].PHP_EOL.PHP_EOL;  | 
                                                        |
| 68 | 68 | }  | 
                                                        
| 69 | 69 | }  | 
                                                        
| 70 | 70 | }  | 
                                                        
@@ -298,7 +298,7 @@ discard block  | 
                                                    ||
| 298 | 298 |          else { | 
                                                        
| 299 | 299 | $size = $this->formatSize($len);  | 
                                                        
| 300 | 300 |              echo sprintf('Added %s(%1.1f%s) file to %s', | 
                                                        
| 301 | - $args['FILE_IN_ARCHIVE'], $size[0], $size[1], $args['ARCHIVE']) . PHP_EOL;  | 
                                                        |
| 301 | + $args['FILE_IN_ARCHIVE'], $size[0], $size[1], $args['ARCHIVE']).PHP_EOL;  | 
                                                        |
| 302 | 302 | }  | 
                                                        
| 303 | 303 | }  | 
                                                        
| 304 | 304 | |
@@ -332,7 +332,7 @@ discard block  | 
                                                    ||
| 332 | 332 | if ($archived_files === false)  | 
                                                        
| 333 | 333 | echo 'Error'.PHP_EOL;  | 
                                                        
| 334 | 334 | else  | 
                                                        
| 335 | -                echo 'Created archive ' . $args['ARCHIVE'] . ' with ' . $archived_files . ' file(s) of total size ' . implode('', $this->formatSize(filesize($args['ARCHIVE']))) . PHP_EOL; | 
                                                        |
| 335 | +                echo 'Created archive '.$args['ARCHIVE'].' with '.$archived_files.' file(s) of total size '.implode('', $this->formatSize(filesize($args['ARCHIVE']))).PHP_EOL; | 
                                                        |
| 336 | 336 | }  | 
                                                        
| 337 | 337 | }  | 
                                                        
| 338 | 338 | |
@@ -15,12 +15,14 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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 | |