| Conditions | 10 |
| Paths | 6 |
| Total Lines | 37 |
| Code Lines | 22 |
| 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 |
||
| 31 | public function execute(InputInterface $input, OutputInterface $output) |
||
| 32 | { |
||
| 33 | $formats = Formats::getAllPossibleSupportedFormats(); |
||
| 34 | $format = $input->getArgument('format'); |
||
| 35 | |||
| 36 | if (empty($format) || !isset($formats[$format])) { |
||
| 37 | /** @var QuestionHelper $helper */ |
||
| 38 | $helper = $this->getHelper('question'); |
||
| 39 | |||
| 40 | |||
| 41 | $question = new ChoiceQuestion('Which format', array_keys($formats)); |
||
| 42 | $format = $helper->ask($input, $output, $question); |
||
| 43 | } |
||
| 44 | $output->writeln('Format <info>' . $format . '</info> drivers support'); |
||
| 45 | |||
| 46 | $table = new Table($output); |
||
| 47 | $table->setHeaders(['driver', 'open', 'stream', 'create', 'append', 'update', 'encrypt']); |
||
| 48 | /** |
||
| 49 | * @var int $i |
||
| 50 | * @var BasicDriver $driver |
||
| 51 | */ |
||
| 52 | foreach ($formats[$format] as $i => $driver) { |
||
| 53 | if ($driver::getInstallationInstruction() === null) { |
||
| 54 | $table->setRow($i, [ |
||
| 55 | $driver, |
||
| 56 | '+', |
||
| 57 | $driver::canStream($format) ? '+' : '', |
||
| 58 | $driver::canCreateArchive($format) ? '+' : '', |
||
| 59 | $driver::canAddFiles($format) ? '+' : '', |
||
| 60 | $driver::canDeleteFiles($format) ? '+' : '', |
||
| 61 | $driver::canEncrypt($format) ? '+' : '', |
||
| 62 | ]); |
||
| 63 | } else { |
||
| 64 | $table->setRow($i, [$driver, new TableCell('<error>not installed</error>', ['colspan' => 6])]); |
||
| 65 | } |
||
| 66 | } |
||
| 67 | $table->render(); |
||
| 68 | } |
||
| 70 |