| Conditions | 7 |
| Paths | 12 |
| Total Lines | 55 |
| Code Lines | 26 |
| 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 |
||
| 27 | public function execute(InputInterface $input, OutputInterface $output) |
||
| 28 | { |
||
| 29 | $notInstalled = []; |
||
|
|
|||
| 30 | $drivers = []; |
||
| 31 | /** @var FormatterHelper $formatter */ |
||
| 32 | $formatter = $this->getHelper('formatter'); |
||
| 33 | |||
| 34 | /** @var BasicDriver $driverClass */ |
||
| 35 | foreach (Formats::$drivers as $driverClass) { |
||
| 36 | $description = $driverClass::getDescription(); |
||
| 37 | if (!$driverClass::isInstalled()) { |
||
| 38 | $drivers[$driverClass::TYPE][$driverClass] = [$description, false, $driverClass::getInstallationInstruction()]; |
||
| 39 | // $notInstalled[] = [$driverClass, $description, $install]; |
||
| 40 | } else { |
||
| 41 | $drivers[$driverClass::TYPE][$driverClass] = [$description, true]; |
||
| 42 | } |
||
| 43 | |||
| 44 | // if (!empty($install)) { |
||
| 45 | // } else { |
||
| 46 | // $output->writeln($formatter->formatSection($driverClass, $description) . ': ' . implode(', ', $driverClass::getSupportedFormats())); |
||
| 47 | // } |
||
| 48 | } |
||
| 49 | |||
| 50 | /** @var FormatterHelper $formatter */ |
||
| 51 | $formatter = $this->getHelper('formatter'); |
||
| 52 | $type_match_rules = [ |
||
| 53 | BasicDriver::TYPE_EXTENSION => 'php extension', |
||
| 54 | BasicDriver::TYPE_UTILITIES => 'utilities + php bridge', |
||
| 55 | BasicDriver::TYPE_PURE_PHP => 'pure php', |
||
| 56 | ]; |
||
| 57 | |||
| 58 | foreach ($drivers as $type => $typeDrivers) { |
||
| 59 | foreach ($typeDrivers as $typeDriverClass => $typeDriverConfig) { |
||
| 60 | $type_messages = []; |
||
| 61 | if ($typeDriverConfig[1]) { |
||
| 62 | $type_messages[] = '<info>' . $typeDriverClass . '</info>: ' . $typeDriverConfig[0]; |
||
| 63 | } else { |
||
| 64 | $type_messages[] = '<error>' . $typeDriverClass . '</error>: ' . $typeDriverConfig[0]; |
||
| 65 | $type_messages[] = $this->formatInstallation($typeDriverConfig[2], 4); |
||
| 66 | } |
||
| 67 | $output->writeln($formatter->formatSection( |
||
| 68 | $type_match_rules[$type], |
||
| 69 | implode("\n", $type_messages), $typeDriverConfig[1] ? 'info' : 'error')); |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | // if (!empty($notInstalled)) { |
||
| 74 | // foreach ($notInstalled as $data) { |
||
| 75 | // $output->writeln($formatter->formatSection($data[0], $data[1] . ': ' . implode(', ', $data[0]::getSupportedFormats()), 'error')); |
||
| 76 | // $data[2] = preg_replace('~`(.+?)`~', '<options=bold,underscore>$1</>', $data[2]); |
||
| 77 | // $output->writeln($formatter->formatSection($data[0], $data[2], 'comment')); |
||
| 78 | // } |
||
| 79 | // } |
||
| 80 | |||
| 81 | return 0; |
||
| 82 | } |
||
| 95 |