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 TModificationFunctionMappingComplexPropertyType extends IsOK |
||
17 | { |
||
18 | use TSimpleIdentifierTrait, TModificationFunctionMappingComplexPropertyPropertyGroup; |
||
19 | /** |
||
20 | * @property string $name |
||
21 | */ |
||
22 | private $name = null; |
||
23 | |||
24 | /** |
||
25 | * @property string $typeName |
||
26 | */ |
||
27 | private $typeName = null; |
||
28 | |||
29 | /** |
||
30 | * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingScalarPropertyType |
||
31 | * $scalarProperty |
||
32 | */ |
||
33 | private $scalarProperty = null; |
||
34 | |||
35 | /** |
||
36 | * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingComplexPropertyType |
||
37 | * $complexProperty |
||
38 | */ |
||
39 | private $complexProperty = null; |
||
40 | |||
41 | /** |
||
42 | * Gets as name |
||
43 | * |
||
44 | * @return string |
||
45 | */ |
||
46 | public function getName() |
||
50 | |||
51 | /** |
||
52 | * Sets a new name |
||
53 | * |
||
54 | * @param string $name |
||
55 | * @return self |
||
56 | */ |
||
57 | public function setName($name) |
||
62 | |||
63 | /** |
||
64 | * Gets as typeName |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | public function getTypeName() |
||
72 | |||
73 | /** |
||
74 | * Sets a new typeName |
||
75 | * |
||
76 | * @param string $typeName |
||
77 | * @return self |
||
78 | */ |
||
79 | public function setTypeName($typeName) |
||
84 | |||
85 | /** |
||
86 | * Gets as scalarProperty |
||
87 | * |
||
88 | * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingScalarPropertyType |
||
89 | */ |
||
90 | public function getScalarProperty() |
||
94 | |||
95 | /** |
||
96 | * Sets a new scalarProperty |
||
97 | * |
||
98 | * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingScalarPropertyType |
||
99 | * $scalarProperty |
||
100 | * @return self |
||
101 | */ |
||
102 | public function setScalarProperty(TModificationFunctionMappingScalarPropertyType $scalarProperty) |
||
107 | |||
108 | /** |
||
109 | * Gets as complexProperty |
||
110 | * |
||
111 | * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingComplexPropertyType |
||
112 | */ |
||
113 | public function getComplexProperty() |
||
117 | |||
118 | /** |
||
119 | * Sets a new complexProperty |
||
120 | * |
||
121 | * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TModificationFunctionMappingComplexPropertyType |
||
122 | * $complexProperty |
||
123 | * @return self |
||
124 | */ |
||
125 | public function setComplexProperty(TModificationFunctionMappingComplexPropertyType $complexProperty) |
||
130 | |||
131 | View Code Duplication | public function isOK(&$msg = null) |
|
150 | } |
||
151 |
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.