@@ -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 | } |
@@ -26,14 +26,14 @@ |
||
| 26 | 26 | $file = realpath($input->getArgument('archive')); |
| 27 | 27 | $archive = $this->getArchive($input, $output); |
| 28 | 28 | |
| 29 | - $output->writeln('Filename: ' . $file . ' (changed <comment>' . $this->formatDate(filemtime($file)) . '</comment>)'); |
|
| 30 | - $output->writeln('Type: <info>' . $archive->getFormat() . '</info>, mime <info>' . $archive->getMimeType() . '</info> (via driver <comment>' . $archive->getDriverType() . '</comment>)'); |
|
| 31 | - $output->writeln('Contains: ' . $archive->countFiles() . ' file' . ($archive->countFiles() > 1 ? 's' : null)); |
|
| 29 | + $output->writeln('Filename: '.$file.' (changed <comment>'.$this->formatDate(filemtime($file)).'</comment>)'); |
|
| 30 | + $output->writeln('Type: <info>'.$archive->getFormat().'</info>, mime <info>'.$archive->getMimeType().'</info> (via driver <comment>'.$archive->getDriverType().'</comment>)'); |
|
| 31 | + $output->writeln('Contains: '.$archive->countFiles().' file'.($archive->countFiles() > 1 ? 's' : null)); |
|
| 32 | 32 | $output->writeln('Size:'); |
| 33 | - $output->writeln("\t". 'uncompressed: '.implode(' ', $this->formatSize($archive->getOriginalSize(), 2))); |
|
| 34 | - $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($archive->getCompressedSize(), 2))); |
|
| 35 | - $output->writeln("\t" . 'ratio: <info>' . round($archive->getOriginalSize() / $archive->getCompressedSize(), 6) . '/1 (' . floor($archive->getCompressedSize() / $archive->getOriginalSize() * 100) . '%</info>)'); |
|
| 33 | + $output->writeln("\t".'uncompressed: '.implode(' ', $this->formatSize($archive->getOriginalSize(), 2))); |
|
| 34 | + $output->writeln("\t".'compressed: '.implode(' ', $this->formatSize($archive->getCompressedSize(), 2))); |
|
| 35 | + $output->writeln("\t".'ratio: <info>'.round($archive->getOriginalSize() / $archive->getCompressedSize(), 6).'/1 ('.floor($archive->getCompressedSize() / $archive->getOriginalSize() * 100).'%</info>)'); |
|
| 36 | 36 | if (!empty($comment = $archive->getComment())) |
| 37 | - $output->writeln('Comment: <comment>' . $comment . '</comment>'); |
|
| 37 | + $output->writeln('Comment: <comment>'.$comment.'</comment>'); |
|
| 38 | 38 | } |
| 39 | 39 | } |
@@ -33,7 +33,8 @@ |
||
| 33 | 33 | $output->writeln("\t". 'uncompressed: '.implode(' ', $this->formatSize($archive->getOriginalSize(), 2))); |
| 34 | 34 | $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($archive->getCompressedSize(), 2))); |
| 35 | 35 | $output->writeln("\t" . 'ratio: <info>' . round($archive->getOriginalSize() / $archive->getCompressedSize(), 6) . '/1 (' . floor($archive->getCompressedSize() / $archive->getOriginalSize() * 100) . '%</info>)'); |
| 36 | - if (!empty($comment = $archive->getComment())) |
|
| 37 | - $output->writeln('Comment: <comment>' . $comment . '</comment>'); |
|
| 36 | + if (!empty($comment = $archive->getComment())) { |
|
| 37 | + $output->writeln('Comment: <comment>' . $comment . '</comment>'); |
|
| 38 | + } |
|
| 38 | 39 | } |
| 39 | 40 | } |
@@ -33,6 +33,6 @@ |
||
| 33 | 33 | $entry_selector = $input->getArgument('entrySelector'); |
| 34 | 34 | |
| 35 | 35 | $archive->extractFiles($output_dir, $entry_selector, true); |
| 36 | - $output->writeln('<info>Extracted:</info> ' . implode(', ', $entry_selector) . ' (' . count($entry_selector) . ') file(s)'); |
|
| 36 | + $output->writeln('<info>Extracted:</info> '.implode(', ', $entry_selector).' ('.count($entry_selector).') file(s)'); |
|
| 37 | 37 | } |
| 38 | 38 | } |
@@ -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 | } |
@@ -33,6 +33,6 @@ |
||
| 33 | 33 | list($archive, $file) = $this->getArchiveAndFile($input, $output); |
| 34 | 34 | |
| 35 | 35 | $archive->deleteFiles($file); |
| 36 | - $output->writeln('<comment>- file "' . $file . '"</comment>'); |
|
| 36 | + $output->writeln('<comment>- file "'.$file.'"</comment>'); |
|
| 37 | 37 | } |
| 38 | 38 | } |
@@ -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 | |