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 |
||
9 | trait TEntityTypeModificationFunctionMappingPropertyGroup |
||
10 | { |
||
11 | /** |
||
12 | * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingScalarPropertyType |
||
13 | * $scalarProperty |
||
14 | */ |
||
15 | private $scalarProperty = null; |
||
16 | |||
17 | /** |
||
18 | * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingAssociationEndType |
||
19 | * $associationEnd |
||
20 | */ |
||
21 | private $associationEnd = null; |
||
22 | |||
23 | /** |
||
24 | * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingComplexPropertyType |
||
25 | * $complexProperty |
||
26 | */ |
||
27 | private $complexProperty = null; |
||
28 | |||
29 | /** |
||
30 | * Gets as scalarProperty |
||
31 | * |
||
32 | * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingScalarPropertyType |
||
33 | */ |
||
34 | public function getScalarProperty() |
||
38 | |||
39 | /** |
||
40 | * Sets a new scalarProperty |
||
41 | * |
||
42 | * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingScalarPropertyType |
||
43 | * $scalarProperty |
||
44 | * @return self |
||
45 | */ |
||
46 | public function setScalarProperty(TModificationFunctionMappingScalarPropertyType $scalarProperty) |
||
51 | |||
52 | /** |
||
53 | * Gets as associationEnd |
||
54 | * |
||
55 | * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingAssociationEndType |
||
56 | */ |
||
57 | public function getAssociationEnd() |
||
61 | |||
62 | /** |
||
63 | * Sets a new associationEnd |
||
64 | * |
||
65 | * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingAssociationEndType |
||
66 | * $associationEnd |
||
67 | * @return self |
||
68 | */ |
||
69 | public function setAssociationEnd(TModificationFunctionMappingAssociationEndType $associationEnd) |
||
74 | |||
75 | /** |
||
76 | * Gets as complexProperty |
||
77 | * |
||
78 | * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingComplexPropertyType |
||
79 | */ |
||
80 | public function getComplexProperty() |
||
84 | |||
85 | /** |
||
86 | * Sets a new complexProperty |
||
87 | * |
||
88 | * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingComplexPropertyType |
||
89 | * $complexProperty |
||
90 | * @return self |
||
91 | */ |
||
92 | public function setComplexProperty(TModificationFunctionMappingComplexPropertyType $complexProperty) |
||
97 | |||
98 | View Code Duplication | public function isMappingPropertyGroupOK(&$msg = null) |
|
111 | } |
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.