@@ -459,13 +459,15 @@ discard block |
||
459 | 459 | */ |
460 | 460 | public function getFiles($filter = null) |
461 | 461 | { |
462 | - if ($filter === null) |
|
463 | - return $this->files; |
|
462 | + if ($filter === null) { |
|
463 | + return $this->files; |
|
464 | + } |
|
464 | 465 | |
465 | 466 | $result = []; |
466 | 467 | foreach ($this->files as $file) { |
467 | - if (fnmatch($filter, $file)) |
|
468 | - $result[] = $file; |
|
468 | + if (fnmatch($filter, $file)) { |
|
469 | + $result[] = $file; |
|
470 | + } |
|
469 | 471 | } |
470 | 472 | return $result; |
471 | 473 | } |
@@ -667,9 +669,9 @@ discard block |
||
667 | 669 | if (is_array($nodes)) { |
668 | 670 | foreach ($nodes as $destination => $source) { |
669 | 671 | // new format |
670 | - if (is_numeric($destination)) |
|
671 | - $destination = $source; |
|
672 | - else { |
|
672 | + if (is_numeric($destination)) { |
|
673 | + $destination = $source; |
|
674 | + } else { |
|
673 | 675 | // old format |
674 | 676 | if (is_string($source) && !file_exists($source)) { |
675 | 677 | list($destination, $source) = [$source, $destination]; |
@@ -728,8 +730,9 @@ discard block |
||
728 | 730 | // $map[$destination] = rtrim($source, '/*'); |
729 | 731 | // do not map root archive folder |
730 | 732 | |
731 | - if ($destination !== null) |
|
732 | - $map[$destination] = null; |
|
733 | + if ($destination !== null) { |
|
734 | + $map[$destination] = null; |
|
735 | + } |
|
733 | 736 | |
734 | 737 | foreach (glob($source, GLOB_MARK) as $node) { |
735 | 738 | if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) { |
@@ -975,8 +978,9 @@ discard block |
||
975 | 978 | */ |
976 | 979 | public static function archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null) |
977 | 980 | { |
978 | - if (!is_dir($directory) || !is_readable($directory)) |
|
979 | - throw new InvalidArgumentException($directory . ' is not a valid directory to archive'); |
|
981 | + if (!is_dir($directory) || !is_readable($directory)) { |
|
982 | + throw new InvalidArgumentException($directory . ' is not a valid directory to archive'); |
|
983 | + } |
|
980 | 984 | |
981 | 985 | return static::create($directory, $archiveName, $compressionLevel, $password) > 0; |
982 | 986 | } |
@@ -1137,8 +1141,9 @@ discard block |
||
1137 | 1141 | */ |
1138 | 1142 | public function addFile($file, $inArchiveName = null) |
1139 | 1143 | { |
1140 | - if (!is_file($file)) |
|
1141 | - throw new InvalidArgumentException($file . ' is not a valid file to add in archive'); |
|
1144 | + if (!is_file($file)) { |
|
1145 | + throw new InvalidArgumentException($file . ' is not a valid file to add in archive'); |
|
1146 | + } |
|
1142 | 1147 | |
1143 | 1148 | return ($inArchiveName !== null |
1144 | 1149 | ? $this->add([$inArchiveName => $file]) |
@@ -1158,8 +1163,9 @@ discard block |
||
1158 | 1163 | */ |
1159 | 1164 | public function addDirectory($directory, $inArchivePath = null) |
1160 | 1165 | { |
1161 | - if (!is_dir($directory) || !is_readable($directory)) |
|
1162 | - throw new InvalidArgumentException($directory . ' is not a valid directory to add in archive'); |
|
1166 | + if (!is_dir($directory) || !is_readable($directory)) { |
|
1167 | + throw new InvalidArgumentException($directory . ' is not a valid directory to add in archive'); |
|
1168 | + } |
|
1163 | 1169 | |
1164 | 1170 | return ($inArchivePath !== null |
1165 | 1171 | ? $this->add([$inArchivePath => $directory]) |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | public static function open($fileName, $abilities = [], $password = null) |
65 | 65 | { |
66 | 66 | if (!file_exists($fileName) || !is_readable($fileName)) { |
67 | - throw new InvalidArgumentException('Could not open file: ' . $fileName . ' is not readable'); |
|
67 | + throw new InvalidArgumentException('Could not open file: '.$fileName.' is not readable'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $format = Formats::detectArchiveFormat($fileName); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if ($archiveName !== null) { |
113 | 113 | $archiveType = Formats::detectArchiveFormat($archiveName, false); |
114 | 114 | if ($archiveType === null) { |
115 | - throw new UnsupportedArchiveException('Could not detect archive type for name "' . $archiveName . '"'); |
|
115 | + throw new UnsupportedArchiveException('Could not detect archive type for name "'.$archiveName.'"'); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | ) |
179 | 179 | { |
180 | 180 | if (file_exists($archiveName)) { |
181 | - throw new FileAlreadyExistsException('Archive ' . $archiveName . ' already exists!'); |
|
181 | + throw new FileAlreadyExistsException('Archive '.$archiveName.' already exists!'); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $info = static::prepareForArchiving($fileOrFiles, $archiveName); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $fileProgressCallable = null |
230 | 230 | ) |
231 | 231 | { |
232 | - $info = static::prepareForArchiving($fileOrFiles, '.' . Formats::getFormatExtension($archiveFormat)); |
|
232 | + $info = static::prepareForArchiving($fileOrFiles, '.'.Formats::getFormatExtension($archiveFormat)); |
|
233 | 233 | try { |
234 | 234 | $driver = static::getCreationDriver($archiveFormat, true, $password !== null); |
235 | 235 | } catch (UnsupportedArchiveException $e) { |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | protected static function getCreationDriver($archiveFormat, $inString, $encrypted) |
254 | 254 | { |
255 | 255 | if (!Formats::canCreate($archiveFormat)) { |
256 | - throw new UnsupportedArchiveException('Unsupported archive type: ' . $archiveFormat); |
|
256 | + throw new UnsupportedArchiveException('Unsupported archive type: '.$archiveFormat); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | $abilities = [Abilities::CREATE]; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | |
264 | 264 | if ($encrypted) { |
265 | 265 | if (!Formats::canEncrypt($archiveFormat)) { |
266 | - throw new UnsupportedOperationException('Archive type ' . $archiveFormat . ' can not be encrypted'); |
|
266 | + throw new UnsupportedOperationException('Archive type '.$archiveFormat.' can not be encrypted'); |
|
267 | 267 | } |
268 | 268 | $abilities[] = Abilities::CREATE_ENCRYPTED; |
269 | 269 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | /** @var BasicDriver $driver */ |
272 | 272 | $driver = Formats::getFormatDriver($archiveFormat, $abilities); |
273 | 273 | if ($driver === null) { |
274 | - throw new UnsupportedArchiveException('Unsupported archive type: ' . $archiveFormat . ' of archive '); |
|
274 | + throw new UnsupportedArchiveException('Unsupported archive type: '.$archiveFormat.' of archive '); |
|
275 | 275 | } |
276 | 276 | return $driver; |
277 | 277 | } |
@@ -295,10 +295,10 @@ discard block |
||
295 | 295 | $driver = Formats::getFormatDriver($format, $abilities); |
296 | 296 | if ($driver === null) { |
297 | 297 | throw new UnsupportedArchiveException( |
298 | - 'Format ' . $format . ' driver with abilities (' |
|
298 | + 'Format '.$format.' driver with abilities (' |
|
299 | 299 | . implode( |
300 | 300 | ', ', |
301 | - array_map(function ($ability) { |
|
301 | + array_map(function($ability) { |
|
302 | 302 | return array_search($ability, Abilities::$abilitiesLabels); |
303 | 303 | }, $abilities) |
304 | 304 | ) |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | public function getFileData($fileName) |
493 | 493 | { |
494 | 494 | if (!in_array($fileName, $this->files, true)) { |
495 | - throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive'); |
|
495 | + throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive'); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | return $this->archive->getFileData($fileName); |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | public function getFileContent($fileName) |
509 | 509 | { |
510 | 510 | if (!in_array($fileName, $this->files, true)) { |
511 | - throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive'); |
|
511 | + throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive'); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | return $this->archive->getFileContent($fileName); |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | public function getFileStream($fileName) |
525 | 525 | { |
526 | 526 | if (!in_array($fileName, $this->files, true)) { |
527 | - throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive'); |
|
527 | + throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive'); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | return $this->archive->getFileStream($fileName); |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | $newFiles = []; |
660 | 660 | foreach ($files as $file) { |
661 | 661 | foreach ($archiveFiles as $archiveFile) { |
662 | - if (fnmatch($file . '*', $archiveFile)) { |
|
662 | + if (fnmatch($file.'*', $archiveFile)) { |
|
663 | 663 | $newFiles[] = $archiveFile; |
664 | 664 | } |
665 | 665 | } |
@@ -692,8 +692,8 @@ discard block |
||
692 | 692 | if (is_array($source)) { |
693 | 693 | foreach ($source as $sourceItem) { |
694 | 694 | static::importFilesFromDir( |
695 | - rtrim($sourceItem, '/\\*') . '/*', |
|
696 | - !empty($destination) ? $destination . '/' : null, |
|
695 | + rtrim($sourceItem, '/\\*').'/*', |
|
696 | + !empty($destination) ? $destination.'/' : null, |
|
697 | 697 | true, |
698 | 698 | $files |
699 | 699 | ); |
@@ -701,8 +701,8 @@ discard block |
||
701 | 701 | } else if (is_dir($source)) { |
702 | 702 | // one source for directories |
703 | 703 | static::importFilesFromDir( |
704 | - rtrim($source, '/\\*') . '/*', |
|
705 | - !empty($destination) ? $destination . '/' : null, |
|
704 | + rtrim($source, '/\\*').'/*', |
|
705 | + !empty($destination) ? $destination.'/' : null, |
|
706 | 706 | true, |
707 | 707 | $files |
708 | 708 | ); |
@@ -714,9 +714,9 @@ discard block |
||
714 | 714 | } else if (is_string($nodes)) { // passed one file or directory |
715 | 715 | // if is directory |
716 | 716 | if (is_dir($nodes)) { |
717 | - $nodes = rtrim($nodes, '/\\*') . '/'; |
|
717 | + $nodes = rtrim($nodes, '/\\*').'/'; |
|
718 | 718 | static::importFilesFromDir( |
719 | - $nodes . '*', |
|
719 | + $nodes.'*', |
|
720 | 720 | $nodes, |
721 | 721 | true, |
722 | 722 | $files |
@@ -745,10 +745,10 @@ discard block |
||
745 | 745 | |
746 | 746 | foreach (glob($source, GLOB_MARK) as $node) { |
747 | 747 | if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) { |
748 | - static::importFilesFromDir(str_replace('\\', '/', $node) . '*', |
|
749 | - $destination . basename($node) . '/', $recursive, $map); |
|
748 | + static::importFilesFromDir(str_replace('\\', '/', $node).'*', |
|
749 | + $destination.basename($node).'/', $recursive, $map); |
|
750 | 750 | } elseif (is_file($node) && is_readable($node)) { |
751 | - $map[$destination . basename($node)] = $node; |
|
751 | + $map[$destination.basename($node)] = $node; |
|
752 | 752 | } |
753 | 753 | } |
754 | 754 | } |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | public static function archiveFile($file, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null) |
968 | 968 | { |
969 | 969 | if (!is_file($file)) { |
970 | - throw new InvalidArgumentException($file . ' is not a valid file to archive'); |
|
970 | + throw new InvalidArgumentException($file.' is not a valid file to archive'); |
|
971 | 971 | } |
972 | 972 | |
973 | 973 | return static::create($file, $archiveName, $compressionLevel, $password) === 1; |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | public static function archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null) |
989 | 989 | { |
990 | 990 | if (!is_dir($directory) || !is_readable($directory)) |
991 | - throw new InvalidArgumentException($directory . ' is not a valid directory to archive'); |
|
991 | + throw new InvalidArgumentException($directory.' is not a valid directory to archive'); |
|
992 | 992 | |
993 | 993 | return static::create($directory, $archiveName, $compressionLevel, $password) > 0; |
994 | 994 | } |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | public function addFile($file, $inArchiveName = null) |
1151 | 1151 | { |
1152 | 1152 | if (!is_file($file)) |
1153 | - throw new InvalidArgumentException($file . ' is not a valid file to add in archive'); |
|
1153 | + throw new InvalidArgumentException($file.' is not a valid file to add in archive'); |
|
1154 | 1154 | |
1155 | 1155 | return ($inArchiveName !== null |
1156 | 1156 | ? $this->add([$inArchiveName => $file]) |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | public function addDirectory($directory, $inArchivePath = null) |
1172 | 1172 | { |
1173 | 1173 | if (!is_dir($directory) || !is_readable($directory)) |
1174 | - throw new InvalidArgumentException($directory . ' is not a valid directory to add in archive'); |
|
1174 | + throw new InvalidArgumentException($directory.' is not a valid directory to add in archive'); |
|
1175 | 1175 | |
1176 | 1176 | return ($inArchivePath !== null |
1177 | 1177 | ? $this->add([$inArchivePath => $directory]) |
@@ -27,7 +27,7 @@ |
||
27 | 27 | |
28 | 28 | $errored = []; |
29 | 29 | foreach ($files as $file) { |
30 | - $output->write($file . ' ... '); |
|
30 | + $output->write($file.' ... '); |
|
31 | 31 | if ($archive->test($file, $hash) === true) { |
32 | 32 | $output->writeln('<info>ok</info>'); |
33 | 33 | } else { |
@@ -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 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | if (!UnifiedArchive::canOpen($file, !empty($password))) { |
22 | 22 | throw new \Exception( |
23 | - 'Could not open archive ' . $file . '. Try installing suggested packages or run `cam -f` to see formats support.' |
|
23 | + 'Could not open archive '.$file.'. Try installing suggested packages or run `cam -f` to see formats support.' |
|
24 | 24 | ); |
25 | 25 | } |
26 | 26 | |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | protected function resolveDriverName($driver) |
93 | 93 | { |
94 | 94 | if (strpos($driver, '\\') === false) { |
95 | - if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\' . $driver)) { |
|
96 | - $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\' . $driver; |
|
97 | - } else if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\' . $driver)) { |
|
98 | - $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\' . $driver; |
|
95 | + if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\'.$driver)) { |
|
96 | + $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\'.$driver; |
|
97 | + } else if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\'.$driver)) { |
|
98 | + $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\'.$driver; |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | if ($driver[0] !== '\\') { |
@@ -25,8 +25,9 @@ discard block |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | $archive = UnifiedArchive::open($file, [], $password); |
28 | - if ($archive === null) |
|
29 | - throw new \Exception('Could not open archive '.$file); |
|
28 | + if ($archive === null) { |
|
29 | + throw new \Exception('Could not open archive '.$file); |
|
30 | + } |
|
30 | 31 | |
31 | 32 | return $archive; |
32 | 33 | } |
@@ -39,17 +40,18 @@ discard block |
||
39 | 40 | */ |
40 | 41 | public function formatDate($unixtime) |
41 | 42 | { |
42 | - if (strtotime('today') < $unixtime) |
|
43 | - return 'Today, '.date('G:m', $unixtime); |
|
44 | - else if (strtotime('yesterday') < $unixtime) |
|
45 | - return 'Yesterday, '.date('G:m', $unixtime); |
|
46 | - else { |
|
43 | + if (strtotime('today') < $unixtime) { |
|
44 | + return 'Today, '.date('G:m', $unixtime); |
|
45 | + } else if (strtotime('yesterday') < $unixtime) { |
|
46 | + return 'Yesterday, '.date('G:m', $unixtime); |
|
47 | + } else { |
|
47 | 48 | $datetime = new \DateTime(); |
48 | 49 | $datetime->setTimestamp($unixtime); |
49 | - if ($datetime->format('Y') == date('Y')) |
|
50 | - return $datetime->format('d M, H:m'); |
|
51 | - else |
|
52 | - return $datetime->format('d M Y, H:m'); |
|
50 | + if ($datetime->format('Y') == date('Y')) { |
|
51 | + return $datetime->format('d M, H:m'); |
|
52 | + } else { |
|
53 | + return $datetime->format('d M Y, H:m'); |
|
54 | + } |
|
53 | 55 | } |
54 | 56 | } |
55 | 57 |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | if ($driver !== null) { |
35 | 35 | $driver = $this->resolveDriverName($driver); |
36 | 36 | if (!class_exists($driver) || !is_a($driver, BasicDriver::class, true)) { |
37 | - throw new \InvalidArgumentException('Class "' . $driver . '" not found or not in BasicDriver children'); |
|
37 | + throw new \InvalidArgumentException('Class "'.$driver.'" not found or not in BasicDriver children'); |
|
38 | 38 | } |
39 | - $output->writeln('Supported formats by <info>' . $driver . '</info>'); |
|
39 | + $output->writeln('Supported formats by <info>'.$driver.'</info>'); |
|
40 | 40 | |
41 | 41 | $headers = array_keys(Abilities::$abilitiesLabels); |
42 | 42 | array_unshift($headers, 'format'); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | foreach (array_combine(array_values(Abilities::$abilitiesShortCuts), array_keys( |
92 | 92 | Abilities::$abilitiesLabels |
93 | 93 | )) as $shortCut => $label) { |
94 | - $output->writeln('<info>' . $shortCut . '</info> - ' . $label); |
|
94 | + $output->writeln('<info>'.$shortCut.'</info> - '.$label); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | return 0; |
@@ -41,7 +41,7 @@ |
||
41 | 41 | $question = new ChoiceQuestion('Which format', array_keys($formats)); |
42 | 42 | $format = $helper->ask($input, $output, $question); |
43 | 43 | } |
44 | - $output->writeln('Format <info>' . $format . '</info> drivers support'); |
|
44 | + $output->writeln('Format <info>'.$format.'</info> drivers support'); |
|
45 | 45 | |
46 | 46 | $table = new Table($output); |
47 | 47 | $headers = array_keys(Abilities::$abilitiesLabels); |
@@ -27,15 +27,15 @@ |
||
27 | 27 | $file = realpath($input->getArgument('archive')); |
28 | 28 | $archive = $this->getArchive($input, $output); |
29 | 29 | |
30 | - $output->writeln('Filename: ' . $file . ' (changed <comment>' . $this->formatDate(filemtime($file)) . '</comment>)'); |
|
31 | - $output->writeln('Type: <info>' . $archive->getFormat() . '</info>, mime <info>' . $archive->getMimeType() . '</info> (via driver <comment>' . $archive->getDriverType() . '</comment>)'); |
|
32 | - $output->writeln('Contains: ' . $archive->countFiles() . ' file' . ($archive->countFiles() > 1 ? 's' : null)); |
|
30 | + $output->writeln('Filename: '.$file.' (changed <comment>'.$this->formatDate(filemtime($file)).'</comment>)'); |
|
31 | + $output->writeln('Type: <info>'.$archive->getFormat().'</info>, mime <info>'.$archive->getMimeType().'</info> (via driver <comment>'.$archive->getDriverType().'</comment>)'); |
|
32 | + $output->writeln('Contains: '.$archive->countFiles().' file'.($archive->countFiles() > 1 ? 's' : null)); |
|
33 | 33 | $output->writeln('Size:'); |
34 | - $output->writeln("\t". 'uncompressed: '.implode(' ', $this->formatSize($archive->getOriginalSize(), 2))); |
|
35 | - $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($archive->getCompressedSize(), 2))); |
|
36 | - $output->writeln("\t" . 'ratio: <info>' . round($archive->getOriginalSize() / $archive->getCompressedSize(), 6) . '/1 (' . floor($archive->getCompressedSize() / $archive->getOriginalSize() * 100) . '%</info>)'); |
|
34 | + $output->writeln("\t".'uncompressed: '.implode(' ', $this->formatSize($archive->getOriginalSize(), 2))); |
|
35 | + $output->writeln("\t".'compressed: '.implode(' ', $this->formatSize($archive->getCompressedSize(), 2))); |
|
36 | + $output->writeln("\t".'ratio: <info>'.round($archive->getOriginalSize() / $archive->getCompressedSize(), 6).'/1 ('.floor($archive->getCompressedSize() / $archive->getOriginalSize() * 100).'%</info>)'); |
|
37 | 37 | if ($archive->can(Abilities::GET_COMMENT) && !empty($comment = $archive->getComment())) |
38 | - $output->writeln('Comment: <comment>' . $comment . '</comment>'); |
|
38 | + $output->writeln('Comment: <comment>'.$comment.'</comment>'); |
|
39 | 39 | |
40 | 40 | return 0; |
41 | 41 | } |
@@ -34,8 +34,9 @@ |
||
34 | 34 | $output->writeln("\t". 'uncompressed: '.implode(' ', $this->formatSize($archive->getOriginalSize(), 2))); |
35 | 35 | $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($archive->getCompressedSize(), 2))); |
36 | 36 | $output->writeln("\t" . 'ratio: <info>' . round($archive->getOriginalSize() / $archive->getCompressedSize(), 6) . '/1 (' . floor($archive->getCompressedSize() / $archive->getOriginalSize() * 100) . '%</info>)'); |
37 | - if ($archive->can(Abilities::GET_COMMENT) && !empty($comment = $archive->getComment())) |
|
38 | - $output->writeln('Comment: <comment>' . $comment . '</comment>'); |
|
37 | + if ($archive->can(Abilities::GET_COMMENT) && !empty($comment = $archive->getComment())) { |
|
38 | + $output->writeln('Comment: <comment>' . $comment . '</comment>'); |
|
39 | + } |
|
39 | 40 | |
40 | 41 | return 0; |
41 | 42 | } |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | { |
52 | 52 | $suffix = Formats::getFormatExtension(static::FORMAT); |
53 | 53 | if ($suffix === null) { |
54 | - throw new \Exception('Format suffix is empty for ' . static::FORMAT . ', it should be initialized!'); |
|
54 | + throw new \Exception('Format suffix is empty for '.static::FORMAT.', it should be initialized!'); |
|
55 | 55 | } |
56 | 56 | if ($password !== null) { |
57 | - throw new UnsupportedOperationException($suffix . ' archive does not support password!'); |
|
57 | + throw new UnsupportedOperationException($suffix.' archive does not support password!'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | parent::__construct($archiveFileName, $format); |
61 | - $this->inArchiveFileName = basename($archiveFileName, '.' . $suffix); |
|
61 | + $this->inArchiveFileName = basename($archiveFileName, '.'.$suffix); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function extractArchive($outputFolder) |
124 | 124 | { |
125 | - if(method_exists($this, 'streamToFile')){ |
|
125 | + if (method_exists($this, 'streamToFile')) { |
|
126 | 126 | $this->streamToFile($outputFolder.$this->inArchiveFileName); |
127 | - }else{ |
|
127 | + } else { |
|
128 | 128 | $data = $this->getFileContent($this->inArchiveFileName); |
129 | 129 | if ($data === false) |
130 | 130 | throw new ArchiveExtractionException('Could not extract archive'); |
@@ -124,10 +124,11 @@ |
||
124 | 124 | { |
125 | 125 | if(method_exists($this, 'streamToFile')){ |
126 | 126 | $this->streamToFile($outputFolder.$this->inArchiveFileName); |
127 | - }else{ |
|
127 | + } else{ |
|
128 | 128 | $data = $this->getFileContent($this->inArchiveFileName); |
129 | - if ($data === false) |
|
130 | - throw new ArchiveExtractionException('Could not extract archive'); |
|
129 | + if ($data === false) { |
|
130 | + throw new ArchiveExtractionException('Could not extract archive'); |
|
131 | + } |
|
131 | 132 | |
132 | 133 | $size = strlen($data); |
133 | 134 | $written = file_put_contents($outputFolder.$this->inArchiveFileName, $data); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | { |
27 | 27 | $fp = fopen($file, 'rb'); |
28 | 28 | if (filesize($file) < 18 || strcmp(fread($fp, 2), "\x1f\x8b")) { |
29 | - return false; // Not GZIP format (See RFC 1952) |
|
29 | + return false; // Not GZIP format (See RFC 1952) |
|
30 | 30 | } |
31 | 31 | $method = fread($fp, 1); |
32 | 32 | $flags = fread($fp, 1); |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | $fp = fopen($targetPath, "w"); |
99 | 99 | while (!gzeof($sfp)) { |
100 | 100 | $chunk = gzread($sfp, 8192); |
101 | - if($chunk === 0 || $chunk === false) |
|
101 | + if ($chunk === 0 || $chunk === false) |
|
102 | 102 | throw new ArchiveExtractionException('Cannot read gzip chunk'); |
103 | - if(fwrite($fp, $chunk, strlen($chunk)) === false) |
|
103 | + if (fwrite($fp, $chunk, strlen($chunk)) === false) |
|
104 | 104 | throw new ArchiveExtractionException('Cannot write gzip chunk'); |
105 | 105 | } |
106 | 106 | gzclose($sfp); |
@@ -98,10 +98,12 @@ |
||
98 | 98 | $fp = fopen($targetPath, "w"); |
99 | 99 | while (!gzeof($sfp)) { |
100 | 100 | $chunk = gzread($sfp, 8192); |
101 | - if($chunk === 0 || $chunk === false) |
|
102 | - throw new ArchiveExtractionException('Cannot read gzip chunk'); |
|
103 | - if(fwrite($fp, $chunk, strlen($chunk)) === false) |
|
104 | - throw new ArchiveExtractionException('Cannot write gzip chunk'); |
|
101 | + if($chunk === 0 || $chunk === false) { |
|
102 | + throw new ArchiveExtractionException('Cannot read gzip chunk'); |
|
103 | + } |
|
104 | + if(fwrite($fp, $chunk, strlen($chunk)) === false) { |
|
105 | + throw new ArchiveExtractionException('Cannot write gzip chunk'); |
|
106 | + } |
|
105 | 107 | } |
106 | 108 | gzclose($sfp); |
107 | 109 | fclose($fp); |