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 |
||
5 | class SBDSummary |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * @var int $RoomIndex |
||
10 | */ |
||
11 | protected $RoomIndex = null; |
||
12 | |||
13 | /** |
||
14 | * @var float $TotalBeforeTaxes |
||
15 | */ |
||
16 | protected $TotalBeforeTaxes = null; |
||
17 | |||
18 | /** |
||
19 | * @var float $TotalTaxes |
||
20 | */ |
||
21 | protected $TotalTaxes = null; |
||
22 | |||
23 | /** |
||
24 | * @var float $InsuranceBeforeTaxes |
||
25 | */ |
||
26 | protected $InsuranceBeforeTaxes = null; |
||
27 | |||
28 | /** |
||
29 | * @var float $InsuranceTaxes |
||
30 | */ |
||
31 | protected $InsuranceTaxes = null; |
||
32 | |||
33 | /** |
||
34 | * @var int $ID_Currency |
||
35 | */ |
||
36 | protected $ID_Currency = null; |
||
37 | |||
38 | /** |
||
39 | * @var RequiredDeposit $RequiredDeposit |
||
40 | */ |
||
41 | protected $RequiredDeposit = null; |
||
42 | |||
43 | /** |
||
44 | * @var float $ResortFeeBeforeTaxes |
||
45 | */ |
||
46 | protected $ResortFeeBeforeTaxes = null; |
||
47 | |||
48 | /** |
||
49 | * @var float $ResortFeeTaxes |
||
50 | */ |
||
51 | protected $ResortFeeTaxes = null; |
||
52 | |||
53 | /** |
||
54 | * @var float $TotalAdvDepositBeforeTaxes |
||
55 | */ |
||
56 | protected $TotalAdvDepositBeforeTaxes = null; |
||
57 | |||
58 | /** |
||
59 | * @var float $TotalAdvDepositTaxes |
||
60 | */ |
||
61 | protected $TotalAdvDepositTaxes = null; |
||
62 | |||
63 | /** |
||
64 | * @var ArrayOfBreakdownByDay $BreakdownList |
||
65 | */ |
||
66 | protected $BreakdownList = null; |
||
67 | |||
68 | /** |
||
69 | * @var float $FirstNightAdvDepositTaxes |
||
70 | */ |
||
71 | protected $FirstNightAdvDepositTaxes = null; |
||
72 | |||
73 | /** |
||
74 | * @var float $FirstNightAdvDepositBeforeTaxes |
||
75 | */ |
||
76 | protected $FirstNightAdvDepositBeforeTaxes = null; |
||
77 | |||
78 | /** |
||
79 | * @param int $RoomIndex |
||
80 | * @param float $TotalBeforeTaxes |
||
81 | * @param float $TotalTaxes |
||
82 | * @param float $InsuranceBeforeTaxes |
||
83 | * @param float $InsuranceTaxes |
||
84 | * @param int $ID_Currency |
||
85 | * @param float $ResortFeeBeforeTaxes |
||
86 | * @param float $ResortFeeTaxes |
||
87 | * @param float $TotalAdvDepositBeforeTaxes |
||
88 | * @param float $TotalAdvDepositTaxes |
||
89 | * @param float $FirstNightAdvDepositTaxes |
||
90 | * @param float $FirstNightAdvDepositBeforeTaxes |
||
91 | */ |
||
92 | View Code Duplication | public function __construct($RoomIndex, $TotalBeforeTaxes, $TotalTaxes, $InsuranceBeforeTaxes, $InsuranceTaxes, $ID_Currency, $ResortFeeBeforeTaxes, $ResortFeeTaxes, $TotalAdvDepositBeforeTaxes, $TotalAdvDepositTaxes, $FirstNightAdvDepositTaxes, $FirstNightAdvDepositBeforeTaxes) |
|
107 | |||
108 | /** |
||
109 | * @return int |
||
110 | */ |
||
111 | public function getRoomIndex() |
||
115 | |||
116 | /** |
||
117 | * @param int $RoomIndex |
||
118 | * @return \Gueststream\PMS\IQWare\API\SBDSummary |
||
119 | */ |
||
120 | public function setRoomIndex($RoomIndex) |
||
125 | |||
126 | /** |
||
127 | * @return float |
||
128 | */ |
||
129 | public function getTotalBeforeTaxes() |
||
133 | |||
134 | /** |
||
135 | * @param float $TotalBeforeTaxes |
||
136 | * @return \Gueststream\PMS\IQWare\API\SBDSummary |
||
137 | */ |
||
138 | public function setTotalBeforeTaxes($TotalBeforeTaxes) |
||
143 | |||
144 | /** |
||
145 | * @return float |
||
146 | */ |
||
147 | public function getTotalTaxes() |
||
151 | |||
152 | /** |
||
153 | * @param float $TotalTaxes |
||
154 | * @return \Gueststream\PMS\IQWare\API\SBDSummary |
||
155 | */ |
||
156 | public function setTotalTaxes($TotalTaxes) |
||
161 | |||
162 | /** |
||
163 | * @return float |
||
164 | */ |
||
165 | public function getInsuranceBeforeTaxes() |
||
169 | |||
170 | /** |
||
171 | * @param float $InsuranceBeforeTaxes |
||
172 | * @return \Gueststream\PMS\IQWare\API\SBDSummary |
||
173 | */ |
||
174 | public function setInsuranceBeforeTaxes($InsuranceBeforeTaxes) |
||
179 | |||
180 | /** |
||
181 | * @return float |
||
182 | */ |
||
183 | public function getInsuranceTaxes() |
||
187 | |||
188 | /** |
||
189 | * @param float $InsuranceTaxes |
||
190 | * @return \Gueststream\PMS\IQWare\API\SBDSummary |
||
191 | */ |
||
192 | public function setInsuranceTaxes($InsuranceTaxes) |
||
197 | |||
198 | /** |
||
199 | * @return int |
||
200 | */ |
||
201 | public function getID_Currency() |
||
205 | |||
206 | /** |
||
207 | * @param int $ID_Currency |
||
208 | * @return \Gueststream\PMS\IQWare\API\SBDSummary |
||
209 | */ |
||
210 | public function setID_Currency($ID_Currency) |
||
215 | |||
216 | /** |
||
217 | * @return RequiredDeposit |
||
218 | */ |
||
219 | public function getRequiredDeposit() |
||
223 | |||
224 | /** |
||
225 | * @param RequiredDeposit $RequiredDeposit |
||
226 | * @return \Gueststream\PMS\IQWare\API\SBDSummary |
||
227 | */ |
||
228 | public function setRequiredDeposit($RequiredDeposit) |
||
233 | |||
234 | /** |
||
235 | * @return float |
||
236 | */ |
||
237 | public function getResortFeeBeforeTaxes() |
||
241 | |||
242 | /** |
||
243 | * @param float $ResortFeeBeforeTaxes |
||
244 | * @return \Gueststream\PMS\IQWare\API\SBDSummary |
||
245 | */ |
||
246 | public function setResortFeeBeforeTaxes($ResortFeeBeforeTaxes) |
||
251 | |||
252 | /** |
||
253 | * @return float |
||
254 | */ |
||
255 | public function getResortFeeTaxes() |
||
259 | |||
260 | /** |
||
261 | * @param float $ResortFeeTaxes |
||
262 | * @return \Gueststream\PMS\IQWare\API\SBDSummary |
||
263 | */ |
||
264 | public function setResortFeeTaxes($ResortFeeTaxes) |
||
269 | |||
270 | /** |
||
271 | * @return float |
||
272 | */ |
||
273 | public function getTotalAdvDepositBeforeTaxes() |
||
277 | |||
278 | /** |
||
279 | * @param float $TotalAdvDepositBeforeTaxes |
||
280 | * @return \Gueststream\PMS\IQWare\API\SBDSummary |
||
281 | */ |
||
282 | public function setTotalAdvDepositBeforeTaxes($TotalAdvDepositBeforeTaxes) |
||
287 | |||
288 | /** |
||
289 | * @return float |
||
290 | */ |
||
291 | public function getTotalAdvDepositTaxes() |
||
295 | |||
296 | /** |
||
297 | * @param float $TotalAdvDepositTaxes |
||
298 | * @return \Gueststream\PMS\IQWare\API\SBDSummary |
||
299 | */ |
||
300 | public function setTotalAdvDepositTaxes($TotalAdvDepositTaxes) |
||
305 | |||
306 | /** |
||
307 | * @return ArrayOfBreakdownByDay |
||
308 | */ |
||
309 | public function getBreakdownList() |
||
313 | |||
314 | /** |
||
315 | * @param ArrayOfBreakdownByDay $BreakdownList |
||
316 | * @return \Gueststream\PMS\IQWare\API\SBDSummary |
||
317 | */ |
||
318 | public function setBreakdownList($BreakdownList) |
||
323 | |||
324 | /** |
||
325 | * @return float |
||
326 | */ |
||
327 | public function getFirstNightAdvDepositTaxes() |
||
331 | |||
332 | /** |
||
333 | * @param float $FirstNightAdvDepositTaxes |
||
334 | * @return \Gueststream\PMS\IQWare\API\SBDSummary |
||
335 | */ |
||
336 | public function setFirstNightAdvDepositTaxes($FirstNightAdvDepositTaxes) |
||
341 | |||
342 | /** |
||
343 | * @return float |
||
344 | */ |
||
345 | public function getFirstNightAdvDepositBeforeTaxes() |
||
349 | |||
350 | /** |
||
351 | * @param float $FirstNightAdvDepositBeforeTaxes |
||
352 | * @return \Gueststream\PMS\IQWare\API\SBDSummary |
||
353 | */ |
||
354 | public function setFirstNightAdvDepositBeforeTaxes($FirstNightAdvDepositBeforeTaxes) |
||
359 | } |
||
360 |
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.