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 |
||
| 12 | class VhostDefineCommand extends ContainerAwareCommand |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * {@inheritDoc} |
||
| 16 | */ |
||
| 17 | protected function configure() |
||
| 26 | |||
| 27 | /** |
||
| 28 | * {@inheritDoc} |
||
| 29 | */ |
||
| 30 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Retrieve vhost's name to process |
||
| 58 | * |
||
| 59 | * @param InputInterface $input |
||
| 60 | * |
||
| 61 | * @return string |
||
| 62 | */ |
||
| 63 | private function getVhost(InputInterface $input) |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @param InputInterface $input |
||
| 75 | * @param OutputInterface $output |
||
| 76 | * |
||
| 77 | * @return VhostConfiguration |
||
| 78 | * |
||
| 79 | * @throws \InvalidArgumentException |
||
| 80 | */ |
||
| 81 | private function getVhostConfiguration(InputInterface $input, OutputInterface $output) |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @param InputInterface $input |
||
| 102 | * @param OutputInterface $output |
||
| 103 | * @param $message |
||
| 104 | */ |
||
| 105 | View Code Duplication | private function comment(InputInterface $input, OutputInterface $output, $message) |
|
| 115 | |||
| 116 | /** |
||
| 117 | * @param InputInterface $input |
||
| 118 | * @param OutputInterface $output |
||
| 119 | * @param $message |
||
| 120 | */ |
||
| 121 | View Code Duplication | private function success(InputInterface $input, OutputInterface $output, $message) |
|
| 131 | |||
| 132 | /** |
||
| 133 | * @param InputInterface $input |
||
| 134 | * @param OutputInterface $output |
||
| 135 | * @return null|\Symfony\Component\Console\Style\SymfonyStyle |
||
| 136 | */ |
||
| 137 | private function getIO(InputInterface $input, OutputInterface $output) |
||
| 145 | } |
||
| 146 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.