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