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 |
||
17 | class TEnumTypeType extends IsOK |
||
18 | { |
||
19 | use IsOKToolboxTrait, TTypeAttributesTrait, TPropertyTypeTrait, AccessTypeTraits; |
||
20 | |||
21 | /** |
||
22 | * @property boolean $isFlags |
||
23 | */ |
||
24 | private $isFlags = null; |
||
25 | |||
26 | /** |
||
27 | * @property string $underlyingType |
||
28 | */ |
||
29 | private $underlyingType = null; |
||
30 | |||
31 | /** |
||
32 | * @property string $typeAccess |
||
33 | */ |
||
34 | private $typeAccess = null; |
||
35 | |||
36 | /** |
||
37 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType $documentation |
||
38 | */ |
||
39 | private $documentation = null; |
||
40 | |||
41 | /** |
||
42 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TEnumTypeMemberType[] $member |
||
43 | */ |
||
44 | private $member = []; |
||
45 | |||
46 | /** |
||
47 | * Gets as isFlags |
||
48 | * |
||
49 | * @return boolean |
||
50 | */ |
||
51 | public function getIsFlags() |
||
55 | |||
56 | /** |
||
57 | * Sets a new isFlags |
||
58 | * |
||
59 | * @param boolean $isFlags |
||
60 | * @return self |
||
61 | */ |
||
62 | public function setIsFlags($isFlags) |
||
67 | |||
68 | /** |
||
69 | * Gets as underlyingType |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | public function getUnderlyingType() |
||
77 | |||
78 | /** |
||
79 | * Sets a new underlyingType |
||
80 | * |
||
81 | * @param string $underlyingType |
||
82 | * @return self |
||
83 | */ |
||
84 | public function setUnderlyingType($underlyingType) |
||
89 | |||
90 | /** |
||
91 | * Gets as typeAccess |
||
92 | * |
||
93 | * @return string |
||
94 | */ |
||
95 | public function getTypeAccess() |
||
99 | |||
100 | /** |
||
101 | * Sets a new typeAccess |
||
102 | * |
||
103 | * @param string $typeAccess |
||
104 | * @return self |
||
105 | */ |
||
106 | public function setTypeAccess($typeAccess) |
||
111 | |||
112 | /** |
||
113 | * Gets as documentation |
||
114 | * |
||
115 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType |
||
116 | */ |
||
117 | public function getDocumentation() |
||
121 | |||
122 | /** |
||
123 | * Sets a new documentation |
||
124 | * |
||
125 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType $documentation |
||
126 | * @return self |
||
127 | */ |
||
128 | public function setDocumentation(TDocumentationType $documentation) |
||
133 | |||
134 | /** |
||
135 | * Adds as member |
||
136 | * |
||
137 | * @return self |
||
138 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TEnumTypeMemberType $member |
||
139 | */ |
||
140 | public function addToMember(TEnumTypeMemberType $member) |
||
145 | |||
146 | /** |
||
147 | * isset member |
||
148 | * |
||
149 | * @param scalar $index |
||
150 | * @return boolean |
||
151 | */ |
||
152 | public function issetMember($index) |
||
156 | |||
157 | /** |
||
158 | * unset member |
||
159 | * |
||
160 | * @param scalar $index |
||
161 | * @return void |
||
162 | */ |
||
163 | public function unsetMember($index) |
||
167 | |||
168 | /** |
||
169 | * Gets as member |
||
170 | * |
||
171 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TEnumTypeMemberType[] |
||
172 | */ |
||
173 | public function getMember() |
||
177 | |||
178 | /** |
||
179 | * Sets a new member |
||
180 | * |
||
181 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TEnumTypeMemberType[] $member |
||
182 | * @return self |
||
183 | */ |
||
184 | public function setMember(array $member) |
||
189 | |||
190 | View Code Duplication | public function isOK(&$msg = null) |
|
216 | } |
||
217 |
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.