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 | class TEntityTypeShapeType extends IsOK |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @property string $entityType |
||
18 | */ |
||
19 | private $entityType = null; |
||
20 | |||
21 | /** |
||
22 | * @property float $pointX |
||
23 | */ |
||
24 | private $pointX = null; |
||
25 | |||
26 | /** |
||
27 | * @property float $pointY |
||
28 | */ |
||
29 | private $pointY = null; |
||
30 | |||
31 | /** |
||
32 | * @property float $width |
||
33 | */ |
||
34 | private $width = null; |
||
35 | |||
36 | /** |
||
37 | * @property float $height |
||
38 | */ |
||
39 | private $height = null; |
||
40 | |||
41 | /** |
||
42 | * @property boolean $isExpanded |
||
43 | */ |
||
44 | private $isExpanded = null; |
||
45 | |||
46 | /** |
||
47 | * @property string $fillColor |
||
48 | */ |
||
49 | private $fillColor = null; |
||
50 | |||
51 | /** |
||
52 | * Gets as entityType |
||
53 | * |
||
54 | * @return string |
||
55 | */ |
||
56 | public function getEntityType() |
||
60 | |||
61 | /** |
||
62 | * Sets a new entityType |
||
63 | * |
||
64 | * @param string $entityType |
||
65 | * @return self |
||
66 | */ |
||
67 | public function setEntityType($entityType) |
||
72 | |||
73 | /** |
||
74 | * Gets as pointX |
||
75 | * |
||
76 | * @return float |
||
77 | */ |
||
78 | public function getPointX() |
||
82 | |||
83 | /** |
||
84 | * Sets a new pointX |
||
85 | * |
||
86 | * @param float $pointX |
||
87 | * @return self |
||
88 | */ |
||
89 | public function setPointX($pointX) |
||
94 | |||
95 | /** |
||
96 | * Gets as pointY |
||
97 | * |
||
98 | * @return float |
||
99 | */ |
||
100 | public function getPointY() |
||
104 | |||
105 | /** |
||
106 | * Sets a new pointY |
||
107 | * |
||
108 | * @param float $pointY |
||
109 | * @return self |
||
110 | */ |
||
111 | public function setPointY($pointY) |
||
116 | |||
117 | /** |
||
118 | * Gets as width |
||
119 | * |
||
120 | * @return float |
||
121 | */ |
||
122 | public function getWidth() |
||
126 | |||
127 | /** |
||
128 | * Sets a new width |
||
129 | * |
||
130 | * @param float $width |
||
131 | * @return self |
||
132 | */ |
||
133 | public function setWidth($width) |
||
138 | |||
139 | /** |
||
140 | * Gets as height |
||
141 | * |
||
142 | * @return float |
||
143 | */ |
||
144 | public function getHeight() |
||
148 | |||
149 | /** |
||
150 | * Sets a new height |
||
151 | * |
||
152 | * @param float $height |
||
153 | * @return self |
||
154 | */ |
||
155 | public function setHeight($height) |
||
160 | |||
161 | /** |
||
162 | * Gets as isExpanded |
||
163 | * |
||
164 | * @return boolean |
||
165 | */ |
||
166 | public function getIsExpanded() |
||
170 | |||
171 | /** |
||
172 | * Sets a new isExpanded |
||
173 | * |
||
174 | * @param boolean $isExpanded |
||
175 | * @return self |
||
176 | */ |
||
177 | public function setIsExpanded($isExpanded) |
||
182 | |||
183 | /** |
||
184 | * Gets as fillColor |
||
185 | * |
||
186 | * @return string |
||
187 | */ |
||
188 | public function getFillColor() |
||
192 | |||
193 | /** |
||
194 | * Sets a new fillColor |
||
195 | * |
||
196 | * @param string $fillColor |
||
197 | * @return self |
||
198 | */ |
||
199 | public function setFillColor($fillColor) |
||
204 | |||
205 | /** |
||
206 | * @return bool |
||
207 | */ |
||
208 | public function isOK(&$msg = null) |
||
239 | } |
||
240 |
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.