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