| Conditions | 6 |
| Paths | 12 |
| Total Lines | 68 |
| Code Lines | 29 |
| 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 |
||
| 24 | public function execute(InputInterface $input, OutputInterface $output) |
||
| 25 | { |
||
| 26 | $notInstalled = []; |
||
|
|
|||
| 27 | $drivers = []; |
||
| 28 | /** @var FormatterHelper $formatter */ |
||
| 29 | $formatter = $this->getHelper('formatter'); |
||
| 30 | |||
| 31 | /** @var BasicDriver $driverClass */ |
||
| 32 | foreach (Formats::$drivers as $driverClass) { |
||
| 33 | $description = $driverClass::getDescription(); |
||
| 34 | if (!$driverClass::isInstalled()) { |
||
| 35 | $drivers[$driverClass::TYPE][$driverClass] = [$description, false, $driverClass::getInstallationInstruction()]; |
||
| 36 | // $notInstalled[] = [$driverClass, $description, $install]; |
||
| 37 | } else { |
||
| 38 | $drivers[$driverClass::TYPE][$driverClass] = [$description, true]; |
||
| 39 | } |
||
| 40 | |||
| 41 | // if (!empty($install)) { |
||
| 42 | // } else { |
||
| 43 | // $output->writeln($formatter->formatSection($driverClass, $description) . ': ' . implode(', ', $driverClass::getSupportedFormats())); |
||
| 44 | // } |
||
| 45 | } |
||
| 46 | |||
| 47 | /** @var FormatterHelper $formatter */ |
||
| 48 | $formatter = $this->getHelper('formatter'); |
||
| 49 | |||
| 50 | $table = new Table($output); |
||
| 51 | $table->setStyle('compact'); |
||
| 52 | $table->setHeaders(['driver', 'type', 'description / installation']); |
||
| 53 | |||
| 54 | $i = 0; |
||
| 55 | foreach ($drivers as $type => $typeDrivers) { |
||
| 56 | /** |
||
| 57 | * @var BasicDriver $typeDriverClass |
||
| 58 | * @var array $typeDriverConfig |
||
| 59 | */ |
||
| 60 | foreach ($typeDrivers as $typeDriverClass => $typeDriverConfig) { |
||
| 61 | |||
| 62 | $type_messages = []; |
||
| 63 | if ($typeDriverConfig[1]) { |
||
| 64 | // $type_messages[] = '<info>' . $typeDriverClass . '</info>: ' . $typeDriverConfig[0]; |
||
| 65 | $table->setRow($i++, [ |
||
| 66 | '<info>' . $this->getDriverBaseName($typeDriverClass) . '</info>', |
||
| 67 | BasicDriver::$typeLabels[$typeDriverClass::TYPE], |
||
| 68 | $typeDriverConfig[0], |
||
| 69 | ]); |
||
| 70 | } else { |
||
| 71 | // $type_messages[] = '<error>' . $typeDriverClass . '</error>: ' . $typeDriverConfig[0]; |
||
| 72 | // $type_messages[] = $this->formatInstallation($typeDriverConfig[2], 4); |
||
| 73 | $table->setRow($i++, [ |
||
| 74 | '<comment>' . $this->getDriverBaseName($typeDriverClass) . '</comment>', |
||
| 75 | BasicDriver::$typeLabels[$typeDriverClass::TYPE], |
||
| 76 | $this->formatInstallation($typeDriverConfig[2], 0), |
||
| 77 | ]); |
||
| 78 | } |
||
| 79 | } |
||
| 80 | } |
||
| 81 | $table->render(); |
||
| 82 | |||
| 83 | // if (!empty($notInstalled)) { |
||
| 84 | // foreach ($notInstalled as $data) { |
||
| 85 | // $output->writeln($formatter->formatSection($data[0], $data[1] . ': ' . implode(', ', $data[0]::getSupportedFormats()), 'error')); |
||
| 86 | // $data[2] = preg_replace('~`(.+?)`~', '<options=bold,underscore>$1</>', $data[2]); |
||
| 87 | // $output->writeln($formatter->formatSection($data[0], $data[2], 'comment')); |
||
| 88 | // } |
||
| 89 | // } |
||
| 90 | |||
| 91 | return 0; |
||
| 92 | } |
||
| 105 |