| Conditions | 10 |
| Paths | 528 |
| Total Lines | 48 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 48 | if ($input->getOption('drafts')) { |
||
| 49 | $options['drafts'] = true; |
||
| 50 | $messageOpt .= ' with drafts'; |
||
| 51 | } |
||
| 52 | if ($input->getOption('dry-run')) { |
||
| 53 | $options['dry-run'] = true; |
||
| 54 | $messageOpt .= ' dry-run'; |
||
| 55 | } |
||
| 56 | if ($input->getOption('baseurl')) { |
||
| 57 | $config['baseurl'] = $input->getOption('baseurl'); |
||
| 58 | } |
||
| 59 | if ($input->getOption('destination')) { |
||
| 60 | $config['output']['dir'] = $input->getOption('destination'); |
||
| 61 | $this->fs->dumpFile($this->getPath().'/'.Serve::$tmpDir.'/output', $input->getOption('destination')); |
||
| 62 | } |
||
| 63 | |||
| 64 | try { |
||
| 65 | $output->writeln(sprintf('Building website%s...', $messageOpt)); |
||
| 66 | $output->writeln(sprintf('<comment>Path: %s</comment>', $this->getPath())); |
||
| 67 | $this->getBuilder($output, $config)->build($options); |
||
| 68 | //if ($this->getRoute()->getName() == 'serve') { |
||
| 69 | $this->fs->dumpFile($this->getPath().'/'.Serve::$tmpDir.'/changes.flag', ''); |
||
| 70 | //} |
||
| 71 | } catch (\Exception $e) { |
||
| 72 | throw new \Exception(sprintf('%s', $e->getMessage())); |
||
| 73 | } |
||
| 74 | |||
| 75 | return 0; |
||
| 76 | } |
||
| 77 | } |
||
| 78 |