| Conditions | 14 |
| Paths | 6 |
| Total Lines | 56 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 26 | public function execute(InputInterface $input, OutputInterface $output) |
||
| 27 | { |
||
| 28 | $archive = $this->getArchive($input, $output); |
||
| 29 | $filter = $input->getArgument('filter'); |
||
| 30 | $long_format = $input->getOption('longFormat'); |
||
| 31 | $human_readable_size = $input->getOption('human-readable-size'); |
||
| 32 | |||
| 33 | if (!empty($filter) && strpos($filter, '*') === false) { |
||
|
|
|||
| 34 | $filter .= '*'; |
||
| 35 | } |
||
| 36 | |||
| 37 | if ($long_format) { |
||
| 38 | $uncomp_size_length = $comp_size_length = 0; |
||
| 39 | foreach ($archive->getFileNames($filter) as $file) { |
||
| 40 | $details = $archive->getFileData($file); |
||
| 41 | |||
| 42 | if ($human_readable_size) { |
||
| 43 | $un_comp_size = implode($this->formatSize($details->uncompressedSize)); |
||
| 44 | $comp_size = implode($this->formatSize($details->compressedSize)); |
||
| 45 | } else { |
||
| 46 | $un_comp_size = $details->uncompressedSize; |
||
| 47 | $comp_size = $details->compressedSize; |
||
| 48 | } |
||
| 49 | |||
| 50 | $len = strlen($un_comp_size); |
||
| 51 | if ($len > $uncomp_size_length) { |
||
| 52 | $uncomp_size_length = $len; |
||
| 53 | } |
||
| 54 | $len = strlen($comp_size); |
||
| 55 | if ($len > $comp_size_length) { |
||
| 56 | $comp_size_length = $len; |
||
| 57 | } |
||
| 58 | } |
||
| 59 | |||
| 60 | foreach ($archive->getFileNames($filter) as $file) { |
||
| 61 | $details = $archive->getFileData($file); |
||
| 62 | $output->writeln(($details->isCompressed && $details->uncompressedSize > 0 ? 'x' : '-') |
||
| 63 | . ' ' . str_pad( |
||
| 64 | $human_readable_size ? implode($this->formatSize($details->uncompressedSize)) : $details->uncompressedSize, |
||
| 65 | $uncomp_size_length, |
||
| 66 | ' ', |
||
| 67 | STR_PAD_LEFT) |
||
| 68 | . ' ' . str_pad( |
||
| 69 | $human_readable_size ? implode($this->formatSize($details->compressedSize)) : $details->compressedSize, |
||
| 70 | $comp_size_length, |
||
| 71 | ' ', |
||
| 72 | STR_PAD_LEFT) |
||
| 73 | . ' ' . $this->formatDateShort($details->modificationTime) . ' ' . $details->path); |
||
| 74 | } |
||
| 75 | } else { |
||
| 76 | foreach ($archive->getFileNames($filter) as $file) { |
||
| 77 | $output->writeln($file); |
||
| 78 | } |
||
| 79 | } |
||
| 80 | |||
| 81 | return 0; |
||
| 82 | } |
||
| 97 |