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 |
||
13 | class TMappingFragmentType extends IsOK |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @property string $storeEntitySet |
||
18 | */ |
||
19 | private $storeEntitySet = null; |
||
20 | |||
21 | /** |
||
22 | * @property boolean $makeColumnsDistinct |
||
23 | */ |
||
24 | private $makeColumnsDistinct = null; |
||
25 | |||
26 | /** |
||
27 | * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType $complexProperty |
||
28 | */ |
||
29 | private $complexProperty = null; |
||
30 | |||
31 | /** |
||
32 | * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType $scalarProperty |
||
33 | */ |
||
34 | private $scalarProperty = null; |
||
35 | |||
36 | /** |
||
37 | * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType $condition |
||
38 | */ |
||
39 | private $condition = null; |
||
40 | |||
41 | /** |
||
42 | * Gets as storeEntitySet |
||
43 | * |
||
44 | * @return string |
||
45 | */ |
||
46 | public function getStoreEntitySet() |
||
50 | |||
51 | /** |
||
52 | * Sets a new storeEntitySet |
||
53 | * |
||
54 | * @param string $storeEntitySet |
||
55 | * @return self |
||
56 | */ |
||
57 | public function setStoreEntitySet($storeEntitySet) |
||
62 | |||
63 | /** |
||
64 | * Gets as makeColumnsDistinct |
||
65 | * |
||
66 | * @return boolean |
||
67 | */ |
||
68 | public function getMakeColumnsDistinct() |
||
72 | |||
73 | /** |
||
74 | * Sets a new makeColumnsDistinct |
||
75 | * |
||
76 | * @param boolean $makeColumnsDistinct |
||
77 | * @return self |
||
78 | */ |
||
79 | public function setMakeColumnsDistinct($makeColumnsDistinct) |
||
84 | |||
85 | /** |
||
86 | * Gets as complexProperty |
||
87 | * |
||
88 | * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType |
||
89 | */ |
||
90 | public function getComplexProperty() |
||
94 | |||
95 | /** |
||
96 | * Sets a new complexProperty |
||
97 | * |
||
98 | * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType $complexProperty |
||
99 | * @return self |
||
100 | */ |
||
101 | public function setComplexProperty(TComplexPropertyType $complexProperty) |
||
106 | |||
107 | /** |
||
108 | * Gets as scalarProperty |
||
109 | * |
||
110 | * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType |
||
111 | */ |
||
112 | public function getScalarProperty() |
||
116 | |||
117 | /** |
||
118 | * Sets a new scalarProperty |
||
119 | * |
||
120 | * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType $scalarProperty |
||
121 | * @return self |
||
122 | */ |
||
123 | public function setScalarProperty(TScalarPropertyType $scalarProperty) |
||
128 | |||
129 | /** |
||
130 | * Gets as condition |
||
131 | * |
||
132 | * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType |
||
133 | */ |
||
134 | public function getCondition() |
||
138 | |||
139 | /** |
||
140 | * Sets a new condition |
||
141 | * |
||
142 | * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType $condition |
||
143 | * @return self |
||
144 | */ |
||
145 | public function setCondition(TConditionType $condition) |
||
150 | |||
151 | View Code Duplication | public function isOK(&$msg = null) |
|
168 | } |
||
169 |
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.