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 |
||
16 | class TAssociationEndType extends IsOK |
||
17 | { |
||
18 | use TSimpleIdentifierTrait, TQualifiedNameTrait, TMultiplicityTrait, TOperations; |
||
19 | /** |
||
20 | * @property string $type |
||
21 | */ |
||
22 | private $type = null; |
||
23 | |||
24 | /** |
||
25 | * @property string $role |
||
26 | */ |
||
27 | private $role = null; |
||
28 | |||
29 | /** |
||
30 | * @property string $multiplicity |
||
31 | */ |
||
32 | private $multiplicity = null; |
||
33 | |||
34 | /** |
||
35 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation |
||
36 | */ |
||
37 | private $documentation = null; |
||
38 | |||
39 | /** |
||
40 | * Gets as type |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | public function getType() |
||
48 | |||
49 | /** |
||
50 | * Sets a new type |
||
51 | * |
||
52 | * @param string $type |
||
53 | * @return self |
||
54 | */ |
||
55 | public function setType($type) |
||
64 | |||
65 | /** |
||
66 | * Gets as role |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | public function getRole() |
||
74 | |||
75 | /** |
||
76 | * Sets a new role |
||
77 | * |
||
78 | * @param string $role |
||
79 | * @return self |
||
80 | */ |
||
81 | public function setRole($role) |
||
94 | |||
95 | /** |
||
96 | * Gets as multiplicity |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | public function getMultiplicity() |
||
104 | |||
105 | /** |
||
106 | * Sets a new multiplicity |
||
107 | * |
||
108 | * @param string $multiplicity |
||
109 | * @return self |
||
110 | */ |
||
111 | View Code Duplication | public function setMultiplicity($multiplicity) |
|
125 | |||
126 | /** |
||
127 | * Gets as documentation |
||
128 | * |
||
129 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType |
||
130 | */ |
||
131 | public function getDocumentation() |
||
135 | |||
136 | /** |
||
137 | * Sets a new documentation |
||
138 | * |
||
139 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation |
||
140 | * @return self |
||
141 | */ |
||
142 | View Code Duplication | public function setDocumentation(TDocumentationType $documentation) |
|
151 | |||
152 | public function isOK(&$msg = null) |
||
180 | } |
||
181 |
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.