@@ -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; |
@@ -60,17 +60,17 @@ |
||
60 | 60 | foreach ($archive->getFileNames($filter) as $file) { |
61 | 61 | $details = $archive->getFileData($file); |
62 | 62 | $output->writeln(($details->isCompressed && $details->uncompressedSize > 0 ? 'x' : '-') |
63 | - . ' ' . str_pad( |
|
63 | + . ' '.str_pad( |
|
64 | 64 | $human_readable_size ? implode($this->formatSize($details->uncompressedSize)) : $details->uncompressedSize, |
65 | 65 | $uncomp_size_length, |
66 | 66 | ' ', |
67 | 67 | STR_PAD_LEFT) |
68 | - . ' ' . str_pad( |
|
68 | + . ' '.str_pad( |
|
69 | 69 | $human_readable_size ? implode($this->formatSize($details->compressedSize)) : $details->compressedSize, |
70 | 70 | $comp_size_length, |
71 | 71 | ' ', |
72 | 72 | STR_PAD_LEFT) |
73 | - . ' ' . $this->formatDateShort($details->modificationTime) . ' ' . $details->path); |
|
73 | + . ' '.$this->formatDateShort($details->modificationTime).' '.$details->path); |
|
74 | 74 | } |
75 | 75 | } else { |
76 | 76 | foreach ($archive->getFileNames($filter) as $file) { |