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 |
||
| 10 | class ListBuilderTemplate extends ListBuilder |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | protected $filtersMode = null; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | protected $defaultFiltersVisibility = null; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | protected $filtersModalSize = null; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Retrieve the filters mode parameter defined into the |
||
| 29 | * YAML generator file under the list builder. |
||
| 30 | * |
||
| 31 | * @return string |
||
| 32 | */ |
||
| 33 | public function getFiltersMode() |
||
| 41 | |||
| 42 | public function getDefaultFiltersVisibility() |
||
| 50 | |||
| 51 | public function getFiltersModalSize() |
||
| 59 | |||
| 60 | /** |
||
| 61 | * (non-PHPdoc). |
||
| 62 | * |
||
| 63 | * @see \Admingenerator\GeneratorBundle\Builder\BaseBuilder::getTemplatesToGenerate() |
||
| 64 | */ |
||
| 65 | View Code Duplication | public function getTemplatesToGenerate() |
|
| 74 | } |
||
| 75 |
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.