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 |
||
| 38 | class CliBootstrap extends Application |
||
| 39 | { |
||
| 40 | /** |
||
| 41 | * Layout flag |
||
| 42 | * @var boolean |
||
| 43 | */ |
||
| 44 | protected $layoutFlag = false; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @var InputInterface |
||
| 48 | */ |
||
| 49 | protected $input; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @var OutputInterface |
||
| 53 | */ |
||
| 54 | protected $output; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @param InputInterface $input |
||
| 58 | */ |
||
| 59 | public function setInput(InputInterface $input) |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return InputInterface |
||
| 66 | */ |
||
| 67 | public function getInput() |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @param OutputInterface $output |
||
| 74 | */ |
||
| 75 | public function setOutput(OutputInterface $output) |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @return OutputInterface |
||
| 82 | */ |
||
| 83 | public function getOutput() |
||
| 87 | |||
| 88 | /** |
||
| 89 | * get CLI Request |
||
| 90 | * @return void |
||
| 91 | * @throws ApplicationException |
||
| 92 | */ |
||
| 93 | public function initRequest() |
||
| 107 | |||
| 108 | /** |
||
| 109 | * initConfig |
||
| 110 | * |
||
| 111 | * @return void |
||
| 112 | */ |
||
| 113 | public function initConfig() |
||
| 124 | |||
| 125 | |||
| 126 | /** |
||
| 127 | * Pre process |
||
| 128 | * @return void |
||
| 129 | */ |
||
| 130 | protected function preProcess() |
||
| 135 | |||
| 136 | /** |
||
| 137 | * {@inheritdoc} |
||
| 138 | * |
||
| 139 | * @param string $module |
||
| 140 | * @param string $controller |
||
| 141 | * @param array $params |
||
| 142 | * @return void |
||
| 143 | */ |
||
| 144 | protected function preDispatch($module, $controller, $params = array()) |
||
| 152 | |||
| 153 | /** |
||
| 154 | * Render, is send Response |
||
| 155 | * |
||
| 156 | * @return void |
||
| 157 | */ |
||
| 158 | public function render() |
||
| 181 | |||
| 182 | /** |
||
| 183 | * @return void |
||
| 184 | */ |
||
| 185 | View Code Duplication | public function end() |
|
| 200 | } |
||
| 201 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.