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 |
||
15 | class TAssociationSetMappingType extends IsOK |
||
16 | { |
||
17 | use TSimpleIdentifierTrait, TQualifiedNameTrait; |
||
18 | /** |
||
19 | * @property string $name |
||
20 | */ |
||
21 | private $name = null; |
||
22 | |||
23 | /** |
||
24 | * @property string $typeName |
||
25 | */ |
||
26 | private $typeName = null; |
||
27 | |||
28 | /** |
||
29 | * @property string $storeEntitySet |
||
30 | */ |
||
31 | private $storeEntitySet = null; |
||
32 | |||
33 | /** |
||
34 | * @property string $queryView |
||
35 | */ |
||
36 | private $queryView = null; |
||
37 | |||
38 | /** |
||
39 | * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEndPropertyType[] $endProperty |
||
40 | */ |
||
41 | private $endProperty = []; |
||
42 | |||
43 | /** |
||
44 | * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType[] $condition |
||
45 | */ |
||
46 | private $condition = []; |
||
47 | |||
48 | /** |
||
49 | * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetModificationFunctionMappingType |
||
50 | * $modificationFunctionMapping |
||
51 | */ |
||
52 | private $modificationFunctionMapping = null; |
||
53 | |||
54 | /** |
||
55 | * Gets as name |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | public function getName() |
||
63 | |||
64 | /** |
||
65 | * Sets a new name |
||
66 | * |
||
67 | * @param string $name |
||
68 | * @return self |
||
69 | */ |
||
70 | public function setName($name) |
||
75 | |||
76 | /** |
||
77 | * Gets as typeName |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | public function getTypeName() |
||
85 | |||
86 | /** |
||
87 | * Sets a new typeName |
||
88 | * |
||
89 | * @param string $typeName |
||
90 | * @return self |
||
91 | */ |
||
92 | public function setTypeName($typeName) |
||
97 | |||
98 | /** |
||
99 | * Gets as storeEntitySet |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | public function getStoreEntitySet() |
||
107 | |||
108 | /** |
||
109 | * Sets a new storeEntitySet |
||
110 | * |
||
111 | * @param string $storeEntitySet |
||
112 | * @return self |
||
113 | */ |
||
114 | public function setStoreEntitySet($storeEntitySet) |
||
119 | |||
120 | /** |
||
121 | * Gets as queryView |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | public function getQueryView() |
||
129 | |||
130 | /** |
||
131 | * Sets a new queryView |
||
132 | * |
||
133 | * @param string $queryView |
||
134 | * @return self |
||
135 | */ |
||
136 | public function setQueryView($queryView) |
||
141 | |||
142 | /** |
||
143 | * Adds as endProperty |
||
144 | * |
||
145 | * @return self |
||
146 | * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEndPropertyType $endProperty |
||
147 | */ |
||
148 | public function addToEndProperty(TEndPropertyType $endProperty) |
||
153 | |||
154 | /** |
||
155 | * isset endProperty |
||
156 | * |
||
157 | * @param scalar $index |
||
158 | * @return boolean |
||
159 | */ |
||
160 | public function issetEndProperty($index) |
||
164 | |||
165 | /** |
||
166 | * unset endProperty |
||
167 | * |
||
168 | * @param scalar $index |
||
169 | * @return void |
||
170 | */ |
||
171 | public function unsetEndProperty($index) |
||
175 | |||
176 | /** |
||
177 | * Gets as endProperty |
||
178 | * |
||
179 | * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEndPropertyType[] |
||
180 | */ |
||
181 | public function getEndProperty() |
||
185 | |||
186 | /** |
||
187 | * Sets a new endProperty |
||
188 | * |
||
189 | * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEndPropertyType[] $endProperty |
||
190 | * @return self |
||
191 | */ |
||
192 | public function setEndProperty(array $endProperty) |
||
197 | |||
198 | /** |
||
199 | * Adds as condition |
||
200 | * |
||
201 | * @return self |
||
202 | * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType $condition |
||
203 | */ |
||
204 | public function addToCondition(TConditionType $condition) |
||
209 | |||
210 | /** |
||
211 | * isset condition |
||
212 | * |
||
213 | * @param scalar $index |
||
214 | * @return boolean |
||
215 | */ |
||
216 | public function issetCondition($index) |
||
220 | |||
221 | /** |
||
222 | * unset condition |
||
223 | * |
||
224 | * @param scalar $index |
||
225 | * @return void |
||
226 | */ |
||
227 | public function unsetCondition($index) |
||
231 | |||
232 | /** |
||
233 | * Gets as condition |
||
234 | * |
||
235 | * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType[] |
||
236 | */ |
||
237 | public function getCondition() |
||
241 | |||
242 | /** |
||
243 | * Sets a new condition |
||
244 | * |
||
245 | * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType[] $condition |
||
246 | * @return self |
||
247 | */ |
||
248 | public function setCondition(array $condition) |
||
253 | |||
254 | /** |
||
255 | * Gets as modificationFunctionMapping |
||
256 | * |
||
257 | * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetModificationFunctionMappingType |
||
258 | */ |
||
259 | public function getModificationFunctionMapping() |
||
263 | |||
264 | /** |
||
265 | * Sets a new modificationFunctionMapping |
||
266 | * |
||
267 | * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetModificationFunctionMappingType |
||
268 | * $modificationFunctionMapping |
||
269 | * @return self |
||
270 | */ |
||
271 | public function setModificationFunctionMapping(TAssociationSetModificationFunctionMappingType $modificationFunctionMapping) |
||
276 | |||
277 | public function isOK(&$msg = null) |
||
332 | } |
||
333 |
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.