@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | public static function open($fileName, $password = null) |
| 63 | 63 | { |
| 64 | 64 | if (!file_exists($fileName) || !is_readable($fileName)) { |
| 65 | - throw new InvalidArgumentException('Could not open file: ' . $fileName.' is not readable'); |
|
| 65 | + throw new InvalidArgumentException('Could not open file: '.$fileName.' is not readable'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $format = Formats::detectArchiveFormat($fileName); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | public function getFileData($fileName) |
| 273 | 273 | { |
| 274 | 274 | if (!in_array($fileName, $this->files, true)) { |
| 275 | - throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive'); |
|
| 275 | + throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive'); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | return $this->archive->getFileData($fileName); |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | public function getFileContent($fileName) |
| 289 | 289 | { |
| 290 | 290 | if (!in_array($fileName, $this->files, true)) { |
| 291 | - throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive'); |
|
| 291 | + throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive'); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | return $this->archive->getFileContent($fileName); |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | public function getFileStream($fileName) |
| 305 | 305 | { |
| 306 | 306 | if (!in_array($fileName, $this->files, true)) { |
| 307 | - throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive'); |
|
| 307 | + throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive'); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | return $this->archive->getFileStream($fileName); |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | public static function archiveFile($file, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null) |
| 560 | 560 | { |
| 561 | 561 | if (!is_file($file)) { |
| 562 | - throw new InvalidArgumentException($file . ' is not a valid file to archive'); |
|
| 562 | + throw new InvalidArgumentException($file.' is not a valid file to archive'); |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | return static::archiveFiles($file, $archiveName, $compressionLevel, $password) === 1; |
@@ -630,8 +630,8 @@ discard block |
||
| 630 | 630 | if (is_array($source)) { |
| 631 | 631 | foreach ($source as $sourceItem) { |
| 632 | 632 | static::importFilesFromDir( |
| 633 | - rtrim($sourceItem, '/\\*') . '/*', |
|
| 634 | - !empty($destination) ? $destination . '/' : null, |
|
| 633 | + rtrim($sourceItem, '/\\*').'/*', |
|
| 634 | + !empty($destination) ? $destination.'/' : null, |
|
| 635 | 635 | true, |
| 636 | 636 | $files |
| 637 | 637 | ); |
@@ -639,8 +639,8 @@ discard block |
||
| 639 | 639 | } else if (is_dir($source)) { |
| 640 | 640 | // one source for directories |
| 641 | 641 | static::importFilesFromDir( |
| 642 | - rtrim($source, '/\\*') . '/*', |
|
| 643 | - !empty($destination) ? $destination . '/' : null, |
|
| 642 | + rtrim($source, '/\\*').'/*', |
|
| 643 | + !empty($destination) ? $destination.'/' : null, |
|
| 644 | 644 | true, |
| 645 | 645 | $files |
| 646 | 646 | ); |
@@ -251,13 +251,15 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | public function getFileNames($filter = null) |
| 253 | 253 | { |
| 254 | - if ($filter === null) |
|
| 255 | - return $this->files; |
|
| 254 | + if ($filter === null) { |
|
| 255 | + return $this->files; |
|
| 256 | + } |
|
| 256 | 257 | |
| 257 | 258 | $result = []; |
| 258 | 259 | foreach ($this->files as $file) { |
| 259 | - if (fnmatch($filter, $file)) |
|
| 260 | - $result[] = $file; |
|
| 260 | + if (fnmatch($filter, $file)) { |
|
| 261 | + $result[] = $file; |
|
| 262 | + } |
|
| 261 | 263 | } |
| 262 | 264 | return $result; |
| 263 | 265 | } |
@@ -384,8 +386,9 @@ discard block |
||
| 384 | 386 | { |
| 385 | 387 | $files_list = static::createFilesList($fileOrFiles); |
| 386 | 388 | |
| 387 | - if (empty($files_list)) |
|
| 388 | - throw new EmptyFileListException('Files list is empty!'); |
|
| 389 | + if (empty($files_list)) { |
|
| 390 | + throw new EmptyFileListException('Files list is empty!'); |
|
| 391 | + } |
|
| 389 | 392 | |
| 390 | 393 | $result = $this->archive->addFiles($files_list); |
| 391 | 394 | $this->scanArchive(); |
@@ -404,8 +407,9 @@ discard block |
||
| 404 | 407 | */ |
| 405 | 408 | public function addFile($file, $inArchiveName = null) |
| 406 | 409 | { |
| 407 | - if (!is_file($file)) |
|
| 408 | - throw new InvalidArgumentException($file.' is not a valid file to add in archive'); |
|
| 410 | + if (!is_file($file)) { |
|
| 411 | + throw new InvalidArgumentException($file.' is not a valid file to add in archive'); |
|
| 412 | + } |
|
| 409 | 413 | |
| 410 | 414 | return ($inArchiveName !== null |
| 411 | 415 | ? $this->addFiles([$inArchiveName => $file]) |
@@ -438,8 +442,9 @@ discard block |
||
| 438 | 442 | */ |
| 439 | 443 | public function addDirectory($directory, $inArchivePath = null) |
| 440 | 444 | { |
| 441 | - if (!is_dir($directory) || !is_readable($directory)) |
|
| 442 | - throw new InvalidArgumentException($directory.' is not a valid directory to add in archive'); |
|
| 445 | + if (!is_dir($directory) || !is_readable($directory)) { |
|
| 446 | + throw new InvalidArgumentException($directory.' is not a valid directory to add in archive'); |
|
| 447 | + } |
|
| 443 | 448 | |
| 444 | 449 | return ($inArchivePath !== null |
| 445 | 450 | ? $this->addFiles([$inArchivePath => $directory]) |
@@ -463,13 +468,15 @@ discard block |
||
| 463 | 468 | { |
| 464 | 469 | $archiveType = Formats::detectArchiveFormat($archiveName, false); |
| 465 | 470 | |
| 466 | - if ($archiveType === false) |
|
| 467 | - throw new UnsupportedArchiveException('Could not detect archive type for name "'.$archiveName.'"'); |
|
| 471 | + if ($archiveType === false) { |
|
| 472 | + throw new UnsupportedArchiveException('Could not detect archive type for name "'.$archiveName.'"'); |
|
| 473 | + } |
|
| 468 | 474 | |
| 469 | 475 | $files_list = static::createFilesList($fileOrFiles); |
| 470 | 476 | |
| 471 | - if (empty($files_list)) |
|
| 472 | - throw new EmptyFileListException('Files list is empty!'); |
|
| 477 | + if (empty($files_list)) { |
|
| 478 | + throw new EmptyFileListException('Files list is empty!'); |
|
| 479 | + } |
|
| 473 | 480 | |
| 474 | 481 | $totalSize = 0; |
| 475 | 482 | foreach ($files_list as $fn) { |
@@ -521,16 +528,19 @@ discard block |
||
| 521 | 528 | $fileProgressCallable = null |
| 522 | 529 | ) |
| 523 | 530 | { |
| 524 | - if (file_exists($archiveName)) |
|
| 525 | - throw new FileAlreadyExistsException('Archive '.$archiveName.' already exists!'); |
|
| 531 | + if (file_exists($archiveName)) { |
|
| 532 | + throw new FileAlreadyExistsException('Archive '.$archiveName.' already exists!'); |
|
| 533 | + } |
|
| 526 | 534 | |
| 527 | 535 | $info = static::prepareForArchiving($fileOrFiles, $archiveName); |
| 528 | 536 | |
| 529 | - if (!Formats::canCreate($info['type'])) |
|
| 530 | - throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '.$archiveName); |
|
| 537 | + if (!Formats::canCreate($info['type'])) { |
|
| 538 | + throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '.$archiveName); |
|
| 539 | + } |
|
| 531 | 540 | |
| 532 | - if ($password !== null && !Formats::canEncrypt($info['type'])) |
|
| 533 | - throw new UnsupportedOperationException('Archive type '.$info['type'].' can not be encrypted'); |
|
| 541 | + if ($password !== null && !Formats::canEncrypt($info['type'])) { |
|
| 542 | + throw new UnsupportedOperationException('Archive type '.$info['type'].' can not be encrypted'); |
|
| 543 | + } |
|
| 534 | 544 | |
| 535 | 545 | /** @var BasicDriver $driver */ |
| 536 | 546 | $driver = Formats::getFormatDriver($info['type'], true); |
@@ -578,8 +588,9 @@ discard block |
||
| 578 | 588 | */ |
| 579 | 589 | public static function archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null) |
| 580 | 590 | { |
| 581 | - if (!is_dir($directory) || !is_readable($directory)) |
|
| 582 | - throw new InvalidArgumentException($directory.' is not a valid directory to archive'); |
|
| 591 | + if (!is_dir($directory) || !is_readable($directory)) { |
|
| 592 | + throw new InvalidArgumentException($directory.' is not a valid directory to archive'); |
|
| 593 | + } |
|
| 583 | 594 | |
| 584 | 595 | return static::archiveFiles($directory, $archiveName, $compressionLevel, $password) > 0; |
| 585 | 596 | } |
@@ -615,9 +626,9 @@ discard block |
||
| 615 | 626 | if (is_array($nodes)) { |
| 616 | 627 | foreach ($nodes as $destination => $source) { |
| 617 | 628 | // new format |
| 618 | - if (is_numeric($destination)) |
|
| 619 | - $destination = $source; |
|
| 620 | - else { |
|
| 629 | + if (is_numeric($destination)) { |
|
| 630 | + $destination = $source; |
|
| 631 | + } else { |
|
| 621 | 632 | // old format |
| 622 | 633 | if (is_string($source) && !file_exists($source)) { |
| 623 | 634 | list($destination, $source) = [$source, $destination]; |
@@ -651,11 +662,12 @@ discard block |
||
| 651 | 662 | |
| 652 | 663 | } else if (is_string($nodes)) { // passed one file or directory |
| 653 | 664 | // if is directory |
| 654 | - if (is_dir($nodes)) |
|
| 655 | - static::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true, |
|
| 665 | + if (is_dir($nodes)) { |
|
| 666 | + static::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true, |
|
| 656 | 667 | $files); |
| 657 | - else if (is_file($nodes)) |
|
| 658 | - $files[basename($nodes)] = $nodes; |
|
| 668 | + } else if (is_file($nodes)) { |
|
| 669 | + $files[basename($nodes)] = $nodes; |
|
| 670 | + } |
|
| 659 | 671 | } |
| 660 | 672 | |
| 661 | 673 | return $files; |
@@ -672,8 +684,9 @@ discard block |
||
| 672 | 684 | // $map[$destination] = rtrim($source, '/*'); |
| 673 | 685 | // do not map root archive folder |
| 674 | 686 | |
| 675 | - if ($destination !== null) |
|
| 676 | - $map[$destination] = null; |
|
| 687 | + if ($destination !== null) { |
|
| 688 | + $map[$destination] = null; |
|
| 689 | + } |
|
| 677 | 690 | |
| 678 | 691 | foreach (glob($source, GLOB_MARK) as $node) { |
| 679 | 692 | if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) { |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | if (!empty($previous_comment = $archive->getComment())) { |
| 32 | - $output->writeln('Comment "' . $previous_comment . '" replaced', OutputInterface::OUTPUT_RAW); |
|
| 32 | + $output->writeln('Comment "'.$previous_comment.'" replaced', OutputInterface::OUTPUT_RAW); |
|
| 33 | 33 | } else if ($comment === null) { |
| 34 | 34 | $output->writeln('Comment deleted', OutputInterface::OUTPUT_RAW); |
| 35 | 35 | } else { |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | if (empty($destination)) { |
| 49 | 49 | throw new \LogicException('Source and destination can not be empty'); |
| 50 | 50 | } |
| 51 | - $output->writeln('<info>Read ' . $data_size . ' from input</info>'); |
|
| 51 | + $output->writeln('<info>Read '.$data_size.' from input</info>'); |
|
| 52 | 52 | } else { |
| 53 | 53 | $data_size = filesize($source); |
| 54 | 54 | } |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | } |
| 76 | 76 | if ($added_files === 1) { |
| 77 | 77 | $details = $archive->getFileData($destination); |
| 78 | - $output->writeln('Added <comment>' . $source . '</comment>(' |
|
| 79 | - . implode($this->formatSize($data_size)) . ') as ' |
|
| 80 | - . $destination . ' (' |
|
| 78 | + $output->writeln('Added <comment>'.$source.'</comment>(' |
|
| 79 | + . implode($this->formatSize($data_size)).') as ' |
|
| 80 | + . $destination.' (' |
|
| 81 | 81 | . implode($this->formatSize($details->compressedSize)) |
| 82 | 82 | . ')'); |
| 83 | 83 | } |
@@ -31,18 +31,18 @@ |
||
| 31 | 31 | $detect_mimetype = $input->getOption('detect-mimetype'); |
| 32 | 32 | |
| 33 | 33 | $details = $archive->getFileData($file); |
| 34 | - $output->writeln('File <info>' . $file . '</info>'); |
|
| 34 | + $output->writeln('File <info>'.$file.'</info>'); |
|
| 35 | 35 | if ($detect_mimetype) { |
| 36 | - $output->writeln('Mime type: <info>' . $this->getMimeTypeByStream($archive->getFileStream($file)).'</info>'); |
|
| 36 | + $output->writeln('Mime type: <info>'.$this->getMimeTypeByStream($archive->getFileStream($file)).'</info>'); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $output->writeln('Size:'); |
| 40 | - $output->writeln("\t". 'uncompressed: '.implode(' ', $this->formatSize($details->uncompressedSize, 2))); |
|
| 41 | - $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($details->compressedSize, 2))); |
|
| 42 | - $output->writeln("\t" . 'ratio: <info>' . round($details->uncompressedSize / $details->compressedSize, 6) . '/1 (' . floor($details->compressedSize / $details->uncompressedSize * 100) . '%</info>)'); |
|
| 43 | - $output->writeln('Modificated: ' . $this->formatDate($details->modificationTime)); |
|
| 40 | + $output->writeln("\t".'uncompressed: '.implode(' ', $this->formatSize($details->uncompressedSize, 2))); |
|
| 41 | + $output->writeln("\t".'compressed: '.implode(' ', $this->formatSize($details->compressedSize, 2))); |
|
| 42 | + $output->writeln("\t".'ratio: <info>'.round($details->uncompressedSize / $details->compressedSize, 6).'/1 ('.floor($details->compressedSize / $details->uncompressedSize * 100).'%</info>)'); |
|
| 43 | + $output->writeln('Modificated: '.$this->formatDate($details->modificationTime)); |
|
| 44 | 44 | if (!empty($comment = $details->comment)) |
| 45 | - $output->writeln('Comment: <comment>' . $comment . '</comment>'); |
|
| 45 | + $output->writeln('Comment: <comment>'.$comment.'</comment>'); |
|
| 46 | 46 | |
| 47 | 47 | if (empty($input->getArgument('file'))) { |
| 48 | 48 | $helper = $this->getHelper('question'); |
@@ -41,8 +41,9 @@ |
||
| 41 | 41 | $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($details->compressedSize, 2))); |
| 42 | 42 | $output->writeln("\t" . 'ratio: <info>' . round($details->uncompressedSize / $details->compressedSize, 6) . '/1 (' . floor($details->compressedSize / $details->uncompressedSize * 100) . '%</info>)'); |
| 43 | 43 | $output->writeln('Modificated: ' . $this->formatDate($details->modificationTime)); |
| 44 | - if (!empty($comment = $details->comment)) |
|
| 45 | - $output->writeln('Comment: <comment>' . $comment . '</comment>'); |
|
| 44 | + if (!empty($comment = $details->comment)) { |
|
| 45 | + $output->writeln('Comment: <comment>' . $comment . '</comment>'); |
|
| 46 | + } |
|
| 46 | 47 | |
| 47 | 48 | if (empty($input->getArgument('file'))) { |
| 48 | 49 | $helper = $this->getHelper('question'); |
@@ -88,7 +88,7 @@ |
||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | if ($sort !== null) { |
| 91 | - usort($rows, function (array $a, array $b) use ($sort_field) { |
|
| 91 | + usort($rows, function(array $a, array $b) use ($sort_field) { |
|
| 92 | 92 | if ($a[$sort_field] > $b[$sort_field]) { |
| 93 | 93 | return 1; |
| 94 | 94 | } |
@@ -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 | } |
@@ -33,17 +35,18 @@ discard block |
||
| 33 | 35 | */ |
| 34 | 36 | public function formatDate($unixtime) |
| 35 | 37 | { |
| 36 | - if (strtotime('today') < $unixtime) |
|
| 37 | - return 'Today, '.date('G:m', $unixtime); |
|
| 38 | - else if (strtotime('yesterday') < $unixtime) |
|
| 39 | - return 'Yesterday, '.date('G:m', $unixtime); |
|
| 40 | - else { |
|
| 38 | + if (strtotime('today') < $unixtime) { |
|
| 39 | + return 'Today, '.date('G:m', $unixtime); |
|
| 40 | + } else if (strtotime('yesterday') < $unixtime) { |
|
| 41 | + return 'Yesterday, '.date('G:m', $unixtime); |
|
| 42 | + } else { |
|
| 41 | 43 | $datetime = new \DateTime(); |
| 42 | 44 | $datetime->setTimestamp($unixtime); |
| 43 | - if ($datetime->format('Y') == date('Y')) |
|
| 44 | - return $datetime->format('d M, H:m'); |
|
| 45 | - else |
|
| 46 | - return $datetime->format('d M Y, H:m'); |
|
| 45 | + if ($datetime->format('Y') == date('Y')) { |
|
| 46 | + return $datetime->format('d M, H:m'); |
|
| 47 | + } else { |
|
| 48 | + return $datetime->format('d M Y, H:m'); |
|
| 49 | + } |
|
| 47 | 50 | } |
| 48 | 51 | } |
| 49 | 52 | |
@@ -37,9 +37,9 @@ |
||
| 37 | 37 | $question = new ChoiceQuestion('Which file', $files); |
| 38 | 38 | $file = $helper->ask($input, $output, $question); |
| 39 | 39 | } else if (!in_array($file, $files, true)) { |
| 40 | - throw new \InvalidArgumentException('File "' . $file . '" not found in archive'); |
|
| 40 | + throw new \InvalidArgumentException('File "'.$file.'" not found in archive'); |
|
| 41 | 41 | } |
| 42 | - $output->writeln('<comment>Selecting file ' . $file . '</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE); |
|
| 42 | + $output->writeln('<comment>Selecting file '.$file.'</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE); |
|
| 43 | 43 | |
| 44 | 44 | return [$archive, $file]; |
| 45 | 45 | } |
@@ -29,20 +29,20 @@ |
||
| 29 | 29 | protected function getArchive(InputInterface $input, OutputInterface $output) |
| 30 | 30 | { |
| 31 | 31 | $file = realpath($input->getArgument('archive')); |
| 32 | - $output->writeln('<comment>Opening ' . $file . '</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE); |
|
| 32 | + $output->writeln('<comment>Opening '.$file.'</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE); |
|
| 33 | 33 | if (!is_file($file)) { |
| 34 | - throw new \InvalidArgumentException('File ' . $input->getArgument('archive') . ' is not accessible'); |
|
| 34 | + throw new \InvalidArgumentException('File '.$input->getArgument('archive').' is not accessible'); |
|
| 35 | 35 | } |
| 36 | - $output->writeln('<comment>Format ' . Formats::detectArchiveFormat($file).'</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE); |
|
| 36 | + $output->writeln('<comment>Format '.Formats::detectArchiveFormat($file).'</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE); |
|
| 37 | 37 | $password = $input->getOption('password'); |
| 38 | 38 | if (empty($password)) { |
| 39 | 39 | $password = null; |
| 40 | 40 | } else { |
| 41 | - $output->writeln('<comment>Passing password: ' . strlen($password).'</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE); |
|
| 41 | + $output->writeln('<comment>Passing password: '.strlen($password).'</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE); |
|
| 42 | 42 | } |
| 43 | 43 | $archive = $this->open($file, $password); |
| 44 | - $output->writeln('<comment>Driver ' . $archive->getDriverType() . '</comment>', OutputInterface::VERBOSITY_VERBOSE); |
|
| 45 | - $output->writeln('<comment>Driver abilities: ' . implode(', ', $this->getDriverFormatAbilities($archive->getDriverType(), $archive->getFormat())) . '</comment>', OutputInterface::VERBOSITY_VERBOSE); |
|
| 44 | + $output->writeln('<comment>Driver '.$archive->getDriverType().'</comment>', OutputInterface::VERBOSITY_VERBOSE); |
|
| 45 | + $output->writeln('<comment>Driver abilities: '.implode(', ', $this->getDriverFormatAbilities($archive->getDriverType(), $archive->getFormat())).'</comment>', OutputInterface::VERBOSITY_VERBOSE); |
|
| 46 | 46 | return $archive; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -58,9 +58,9 @@ |
||
| 58 | 58 | $comment = $input->getOption('comment'); |
| 59 | 59 | |
| 60 | 60 | if (file_exists($archive_file)) { |
| 61 | - if (is_dir($archive_file)) |
|
| 62 | - throw new \InvalidArgumentException($archive_file . ' is a directory!'); |
|
| 63 | - else { |
|
| 61 | + if (is_dir($archive_file)) { |
|
| 62 | + throw new \InvalidArgumentException($archive_file . ' is a directory!'); |
|
| 63 | + } else { |
|
| 64 | 64 | throw new \InvalidArgumentException('File "' . $archive_file . '" already exists!'); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $password = $input->getOption('password'); |
| 48 | 48 | $compression = $input->getOption('compression'); |
| 49 | 49 | if (!isset(static::$compressionLevels[$compression])) { |
| 50 | - throw new \InvalidArgumentException('Compression "' . $compression . '" is not valid'); |
|
| 50 | + throw new \InvalidArgumentException('Compression "'.$compression.'" is not valid'); |
|
| 51 | 51 | } |
| 52 | 52 | $compression = static::$compressionLevels[$compression]; |
| 53 | 53 | $path = $input->getOption('path'); |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | if (file_exists($archive_file)) { |
| 61 | 61 | if (is_dir($archive_file)) |
| 62 | - throw new \InvalidArgumentException($archive_file . ' is a directory!'); |
|
| 62 | + throw new \InvalidArgumentException($archive_file.' is a directory!'); |
|
| 63 | 63 | else { |
| 64 | - throw new \InvalidArgumentException('File "' . $archive_file . '" already exists!'); |
|
| 64 | + throw new \InvalidArgumentException('File "'.$archive_file.'" already exists!'); |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | case 'full': |
| 74 | 74 | $destination = ltrim($file_to_pack, '/'); |
| 75 | 75 | $files_list[$destination] = $file_to_pack; |
| 76 | - $output->writeln('<comment>' . $file_to_pack . ' => ' . $destination . '</comment>', OutputInterface::VERBOSITY_VERBOSE); |
|
| 76 | + $output->writeln('<comment>'.$file_to_pack.' => '.$destination.'</comment>', OutputInterface::VERBOSITY_VERBOSE); |
|
| 77 | 77 | break; |
| 78 | 78 | case 'root': |
| 79 | 79 | if (is_dir($file_to_pack)) { |
| 80 | - $output->writeln('<comment>' . $file_to_pack . ' => root</comment>', OutputInterface::VERBOSITY_VERBOSE); |
|
| 80 | + $output->writeln('<comment>'.$file_to_pack.' => root</comment>', OutputInterface::VERBOSITY_VERBOSE); |
|
| 81 | 81 | if (!isset($files_list[''])) { |
| 82 | 82 | $files_list[''] = $file_to_pack; |
| 83 | 83 | } elseif (is_string($files_list[''])) { |
@@ -86,35 +86,35 @@ discard block |
||
| 86 | 86 | $files_list[''][] = $file_to_pack; |
| 87 | 87 | } |
| 88 | 88 | } else { |
| 89 | - $output->writeln('<comment>' . $file_to_pack . ' => ' . basename($file_to_pack) . '</comment>', OutputInterface::VERBOSITY_VERBOSE); |
|
| 89 | + $output->writeln('<comment>'.$file_to_pack.' => '.basename($file_to_pack).'</comment>', OutputInterface::VERBOSITY_VERBOSE); |
|
| 90 | 90 | $files_list[basename($file_to_pack)] = $file_to_pack; |
| 91 | 91 | } |
| 92 | 92 | break; |
| 93 | 93 | case 'relative': |
| 94 | 94 | $destination = ltrim($file_to_pack, '/.'); |
| 95 | 95 | $files_list[$destination] = $file_to_pack; |
| 96 | - $output->writeln('<comment>' . $file_to_pack . ' => ' . $destination . '</comment>', OutputInterface::VERBOSITY_VERBOSE); |
|
| 96 | + $output->writeln('<comment>'.$file_to_pack.' => '.$destination.'</comment>', OutputInterface::VERBOSITY_VERBOSE); |
|
| 97 | 97 | break; |
| 98 | 98 | case 'basename': |
| 99 | 99 | $destination = basename($file_to_pack); |
| 100 | 100 | $files_list[$destination] = $file_to_pack; |
| 101 | - $output->writeln('<comment>' . $file_to_pack . ' => ' . $destination . '</comment>', OutputInterface::VERBOSITY_VERBOSE); |
|
| 101 | + $output->writeln('<comment>'.$file_to_pack.' => '.$destination.'</comment>', OutputInterface::VERBOSITY_VERBOSE); |
|
| 102 | 102 | break; |
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $information = UnifiedArchive::prepareForArchiving($files_list, $archive_file); |
| 107 | 107 | if ($dry_run) { |
| 108 | - $output->writeln('Format: <info>' . $information['type'] . '</info>'); |
|
| 109 | - $output->writeln('Original size: <info>' . implode($this->formatSize($information['totalSize'])) . '</info>'); |
|
| 110 | - $output->writeln('Files: <info>' . $information['numberOfFiles'] . '</info>'); |
|
| 108 | + $output->writeln('Format: <info>'.$information['type'].'</info>'); |
|
| 109 | + $output->writeln('Original size: <info>'.implode($this->formatSize($information['totalSize'])).'</info>'); |
|
| 110 | + $output->writeln('Files: <info>'.$information['numberOfFiles'].'</info>'); |
|
| 111 | 111 | foreach ($information['files'] as $destination => $source) { |
| 112 | 112 | // is folder |
| 113 | 113 | if ($source === null) { |
| 114 | 114 | continue; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $output->writeln($source . ' => <comment>' . $destination . '</comment>'); |
|
| 117 | + $output->writeln($source.' => <comment>'.$destination.'</comment>'); |
|
| 118 | 118 | } |
| 119 | 119 | return 0; |
| 120 | 120 | } |
@@ -124,10 +124,10 @@ discard block |
||
| 124 | 124 | $progressBar = new ProgressBar($output, $information['numberOfFiles']); |
| 125 | 125 | $progressBar->setFormat('archiving'); |
| 126 | 126 | $progressBar->start(); |
| 127 | - $archived_files = UnifiedArchive::archiveFiles($files_list, $archive_file, $compression, $password, function ($currentFile, $totalFiles, $fsFilename, $archiveFilename) |
|
| 127 | + $archived_files = UnifiedArchive::archiveFiles($files_list, $archive_file, $compression, $password, function($currentFile, $totalFiles, $fsFilename, $archiveFilename) |
|
| 128 | 128 | use ($progressBar) { |
| 129 | 129 | if ($fsFilename === null) { |
| 130 | - $progressBar->setMessage('Creating ' . $archiveFilename); |
|
| 130 | + $progressBar->setMessage('Creating '.$archiveFilename); |
|
| 131 | 131 | } else { |
| 132 | 132 | $progressBar->setMessage($fsFilename); |
| 133 | 133 | } |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | $archive->setComment($comment); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - $output->writeln('Created <info>' . $archive_file . '</info> with <comment>' . $archived_files . '</comment> file(s) (' |
|
| 150 | - . implode($this->formatSize($archive->getOriginalSize())) . ') of total size ' |
|
| 149 | + $output->writeln('Created <info>'.$archive_file.'</info> with <comment>'.$archived_files.'</comment> file(s) (' |
|
| 150 | + . implode($this->formatSize($archive->getOriginalSize())).') of total size ' |
|
| 151 | 151 | . implode($this->formatSize(filesize($archive_file)))); |
| 152 | 152 | |
| 153 | 153 | return 0; |