| Conditions | 9 |
| Paths | 256 |
| Total Lines | 54 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 56 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 57 | { |
||
| 58 | $config = []; |
||
| 59 | $options = []; |
||
| 60 | $messageOpt = ''; |
||
| 61 | |||
| 62 | if ($input->getOption('drafts')) { |
||
| 63 | $options['drafts'] = true; |
||
| 64 | $messageOpt .= ' with drafts'; |
||
| 65 | } |
||
| 66 | if ($input->getOption('dry-run')) { |
||
| 67 | $options['dry-run'] = true; |
||
| 68 | $messageOpt .= ' (dry-run)'; |
||
| 69 | } |
||
| 70 | if ($input->getOption('baseurl')) { |
||
| 71 | $config['baseurl'] = $input->getOption('baseurl'); |
||
| 72 | } |
||
| 73 | if ($input->getOption('destination')) { |
||
| 74 | $config['output']['dir'] = $input->getOption('destination'); |
||
| 75 | $this->fs->dumpFile( |
||
| 76 | Util::joinFile($this->getPath(), self::TMP_DIR, 'output'), |
||
| 77 | (string) $input->getOption('destination') |
||
| 78 | ); |
||
| 79 | } |
||
| 80 | if ($input->getOption('postprocess') === null) { |
||
| 81 | $config['postprocess']['enabled'] = true; |
||
| 82 | } |
||
| 83 | if ($input->getOption('postprocess') == 'no') { |
||
| 84 | $config['postprocess']['enabled'] = false; |
||
| 85 | } |
||
| 86 | if ($input->getOption('no-cache')) { |
||
| 87 | $config['cache']['enabled'] = false; |
||
| 88 | } |
||
| 89 | |||
| 90 | $output->writeln(sprintf('Building website%s...', $messageOpt)); |
||
| 91 | $output->writeln( |
||
| 92 | sprintf('<comment>Path: %s</comment>', $this->getPath()), |
||
| 93 | OutputInterface::VERBOSITY_VERBOSE |
||
| 94 | ); |
||
| 95 | |||
| 96 | $builder = $this->getBuilder($config); |
||
| 97 | |||
| 98 | if ((bool) $this->builder->getConfig()->get('cache.enabled')) { |
||
| 99 | $output->writeln( |
||
| 100 | sprintf('<comment>Cache: %s</comment>', $this->builder->getConfig()->getCachePath()), |
||
| 101 | OutputInterface::VERBOSITY_VERBOSE |
||
| 102 | ); |
||
| 103 | } |
||
| 104 | |||
| 105 | $builder->build($options); |
||
| 106 | $this->fs->dumpFile(Util::joinFile($this->getPath(), self::TMP_DIR, 'changes.flag'), time()); |
||
| 107 | $output->writeln('Done! 🎉'); |
||
| 108 | |||
| 109 | return 0; |
||
| 110 | } |
||
| 112 |