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 |
||
18 | class TValueTermType extends IsOK |
||
19 | { |
||
20 | use TFacetAttributesTrait, |
||
21 | GExpressionTrait, |
||
22 | TQualifiedNameTrait, |
||
23 | TSimpleIdentifierTrait, |
||
24 | TWrappedFunctionReturnTrait; |
||
25 | |||
26 | public function __construct() |
||
31 | /** |
||
32 | * @property string $name |
||
33 | */ |
||
34 | private $name = null; |
||
35 | |||
36 | /** |
||
37 | * @property string $type |
||
38 | */ |
||
39 | private $type = null; |
||
40 | |||
41 | /** |
||
42 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType $documentation |
||
43 | */ |
||
44 | private $documentation = null; |
||
45 | |||
46 | /** |
||
47 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType $collectionType |
||
48 | */ |
||
49 | private $collectionType = null; |
||
50 | |||
51 | /** |
||
52 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType $referenceType |
||
53 | */ |
||
54 | private $referenceType = null; |
||
55 | |||
56 | /** |
||
57 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType |
||
58 | */ |
||
59 | private $rowType = null; |
||
60 | |||
61 | /** |
||
62 | * Gets as name |
||
63 | * |
||
64 | * @return string |
||
65 | */ |
||
66 | public function getName() |
||
70 | |||
71 | /** |
||
72 | * Sets a new name |
||
73 | * |
||
74 | * @param string $name |
||
75 | * @return self |
||
76 | */ |
||
77 | public function setName($name) |
||
86 | |||
87 | /** |
||
88 | * Gets as type |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | public function getType() |
||
96 | |||
97 | /** |
||
98 | * Sets a new type |
||
99 | * |
||
100 | * @param string $type |
||
101 | * @return self |
||
102 | */ |
||
103 | public function setType($type) |
||
112 | |||
113 | /** |
||
114 | * Gets as documentation |
||
115 | * |
||
116 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType |
||
117 | */ |
||
118 | public function getDocumentation() |
||
122 | |||
123 | /** |
||
124 | * Sets a new documentation |
||
125 | * |
||
126 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType $documentation |
||
127 | * @return self |
||
128 | */ |
||
129 | View Code Duplication | public function setDocumentation(TDocumentationType $documentation) |
|
138 | |||
139 | /** |
||
140 | * Gets as collectionType |
||
141 | * |
||
142 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType |
||
143 | */ |
||
144 | public function getCollectionType() |
||
148 | |||
149 | /** |
||
150 | * Sets a new collectionType |
||
151 | * |
||
152 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType $collectionType |
||
153 | * @return self |
||
154 | */ |
||
155 | public function setCollectionType(TCollectionTypeType $collectionType) |
||
164 | |||
165 | /** |
||
166 | * Gets as referenceType |
||
167 | * |
||
168 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType |
||
169 | */ |
||
170 | public function getReferenceType() |
||
174 | |||
175 | /** |
||
176 | * Sets a new referenceType |
||
177 | * |
||
178 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType $referenceType |
||
179 | * @return self |
||
180 | */ |
||
181 | public function setReferenceType(TReferenceTypeType $referenceType) |
||
190 | |||
191 | /** |
||
192 | * Adds as property |
||
193 | * |
||
194 | * @return self |
||
195 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType $property |
||
196 | */ |
||
197 | public function addToRowType(TPropertyType $property) |
||
206 | |||
207 | /** |
||
208 | * isset rowType |
||
209 | * |
||
210 | * @param scalar $index |
||
211 | * @return boolean |
||
212 | */ |
||
213 | public function issetRowType($index) |
||
217 | |||
218 | /** |
||
219 | * unset rowType |
||
220 | * |
||
221 | * @param scalar $index |
||
222 | * @return void |
||
223 | */ |
||
224 | public function unsetRowType($index) |
||
228 | |||
229 | /** |
||
230 | * Gets as rowType |
||
231 | * |
||
232 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] |
||
233 | */ |
||
234 | public function getRowType() |
||
238 | |||
239 | /** |
||
240 | * Sets a new rowType |
||
241 | * |
||
242 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType |
||
243 | * @return self |
||
244 | */ |
||
245 | public function setRowType(array $rowType) |
||
257 | |||
258 | public function isOK(&$msg = null) |
||
312 | } |
||
313 |
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.