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 | trait TFunctionImportParameterAttributesTrait |
||
14 | { |
||
15 | use TSimpleIdentifierTrait, TParameterModeTrait, TFunctionImportParameterAndReturnTypeTrait, TMaxLengthFacetTrait, |
||
16 | TPrecisionFacetTrait, TScaleFacetTrait, TSridFacetTrait; |
||
17 | |||
18 | /* |
||
19 | * @property string $name |
||
20 | */ |
||
21 | private $name = null; |
||
22 | |||
23 | /** |
||
24 | * @property string $type |
||
25 | */ |
||
26 | private $type = null; |
||
27 | |||
28 | /** |
||
29 | * @property string $mode |
||
30 | */ |
||
31 | private $mode = null; |
||
32 | |||
33 | /** |
||
34 | * @property string $maxLength |
||
35 | */ |
||
36 | private $maxLength = null; |
||
37 | |||
38 | /** |
||
39 | * @property integer $precision |
||
40 | */ |
||
41 | private $precision = null; |
||
42 | |||
43 | /** |
||
44 | * @property integer $scale |
||
45 | */ |
||
46 | private $scale = null; |
||
47 | |||
48 | /** |
||
49 | * @property string $sRID |
||
50 | */ |
||
51 | private $sRID = null; |
||
52 | |||
53 | /** |
||
54 | * Gets as name |
||
55 | * |
||
56 | * @return string |
||
57 | */ |
||
58 | public function getName() |
||
62 | |||
63 | /** |
||
64 | * Sets a new name |
||
65 | * |
||
66 | * @param string $name |
||
67 | * @return self |
||
68 | */ |
||
69 | View Code Duplication | public function setName($name) |
|
79 | |||
80 | /** |
||
81 | * Gets as type |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | public function getType() |
||
89 | |||
90 | /** |
||
91 | * Sets a new type |
||
92 | * |
||
93 | * @param string $type |
||
94 | * @return self |
||
95 | */ |
||
96 | public function setType($type) |
||
106 | |||
107 | /** |
||
108 | * Gets as mode |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | public function getMode() |
||
116 | |||
117 | /** |
||
118 | * Sets a new mode |
||
119 | * |
||
120 | * @param string $mode |
||
121 | * @return self |
||
122 | */ |
||
123 | public function setMode($mode) |
||
133 | |||
134 | /** |
||
135 | * Gets as maxLength |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | public function getMaxLength() |
||
143 | |||
144 | /** |
||
145 | * Sets a new maxLength |
||
146 | * |
||
147 | * @param string $maxLength |
||
148 | * @return self |
||
149 | */ |
||
150 | View Code Duplication | public function setMaxLength($maxLength) |
|
160 | |||
161 | /** |
||
162 | * Gets as precision |
||
163 | * |
||
164 | * @return integer |
||
165 | */ |
||
166 | public function getPrecision() |
||
170 | |||
171 | /** |
||
172 | * Sets a new precision |
||
173 | * |
||
174 | * @param integer $precision |
||
175 | * @return self |
||
176 | */ |
||
177 | View Code Duplication | public function setPrecision($precision) |
|
187 | |||
188 | /** |
||
189 | * Gets as scale |
||
190 | * |
||
191 | * @return integer |
||
192 | */ |
||
193 | public function getScale() |
||
197 | |||
198 | /** |
||
199 | * Sets a new scale |
||
200 | * |
||
201 | * @param integer $scale |
||
202 | * @return self |
||
203 | */ |
||
204 | View Code Duplication | public function setScale($scale) |
|
214 | |||
215 | /** |
||
216 | * Gets as sRID |
||
217 | * |
||
218 | * @return string |
||
219 | */ |
||
220 | public function getSRID() |
||
224 | |||
225 | /** |
||
226 | * Sets a new sRID |
||
227 | * |
||
228 | * @param string $sRID |
||
229 | * @return self |
||
230 | */ |
||
231 | View Code Duplication | public function setSRID($sRID) |
|
241 | |||
242 | public function isTFunctionImportParameterAttributesValid(&$msg = null) |
||
275 | } |
||
276 |
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.