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 |
||
8 | class RelationFaction extends Faction { |
||
9 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
||
10 | /** |
||
11 | * renvoi la liste des relations d'une faction |
||
12 | */ |
||
13 | View Code Duplication | public function getListeRelation() { |
|
36 | |||
37 | /** |
||
38 | * fonction qui récupère la liste des relations qu'il sera possible |
||
39 | * de mettre dans le select |
||
40 | */ |
||
41 | public function getAllRelationsPossible() { |
||
56 | |||
57 | /** |
||
58 | * @param $relation |
||
59 | * @return array |
||
60 | */ |
||
61 | public function getIdFactionRelation($relation) { |
||
78 | //-------------------------- END GETTER ----------------------------------------------------------------------------// |
||
79 | |||
80 | |||
81 | //-------------------------- SETTER ----------------------------------------------------------------------------// |
||
82 | /** |
||
83 | * @param $nom_faction |
||
84 | * @param $relation |
||
85 | * @return bool |
||
86 | * fonction qui permet d'ajouter une relation |
||
87 | */ |
||
88 | public function setAjouterRelation($nom_faction, $relation) { |
||
101 | |||
102 | //-------------------------- END SETTER ----------------------------------------------------------------------------// |
||
103 | } |
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.