Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 9 | class InstallSampleData extends AbstractSubCommand |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @return bool |
||
|
|
|||
| 13 | */ |
||
| 14 | public function execute() |
||
| 15 | { |
||
| 16 | if ($this->input->getOption('noDownload')) { |
||
| 17 | return false; |
||
| 18 | } |
||
| 19 | |||
| 20 | $installationFolder = $this->config->getString('installationFolder'); |
||
| 21 | chdir($installationFolder); |
||
| 22 | |||
| 23 | $dialog = $this->getCommand()->getHelper('dialog'); |
||
| 24 | |||
| 25 | View Code Duplication | if ($this->input->getOption('installSampleData') !== null) { |
|
| 26 | $installSampleData = $this->getCommand()->parseBoolOption($this->input->getOption('installSampleData')); |
||
| 27 | } else { |
||
| 28 | $installSampleData = $dialog->askConfirmation( |
||
| 29 | $this->output, |
||
| 30 | '<question>Install sample data?</question> <comment>[y]</comment>: ' |
||
| 31 | ); |
||
| 32 | } |
||
| 33 | |||
| 34 | if ($installSampleData) { |
||
| 35 | $this->runSampleDataInstaller(); |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | protected function runSampleDataInstaller() |
||
| 80 | } |
||
| 81 |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.