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 | View Code Duplication | class getAllRoomsAvailabilityForStayFast |
|
|
|||
6 | { |
||
7 | |||
8 | /** |
||
9 | * @var int $guid |
||
10 | */ |
||
11 | protected $guid = null; |
||
12 | |||
13 | /** |
||
14 | * @var string $strRoomIDs |
||
15 | */ |
||
16 | protected $strRoomIDs = null; |
||
17 | |||
18 | /** |
||
19 | * @var string $strRoomTypeIDs |
||
20 | */ |
||
21 | protected $strRoomTypeIDs = null; |
||
22 | |||
23 | /** |
||
24 | * @var string $strRoomAttributeIDs |
||
25 | */ |
||
26 | protected $strRoomAttributeIDs = null; |
||
27 | |||
28 | /** |
||
29 | * @var string $strRoomLocationIDs |
||
30 | */ |
||
31 | protected $strRoomLocationIDs = null; |
||
32 | |||
33 | /** |
||
34 | * @var string $strBuildingIDs |
||
35 | */ |
||
36 | protected $strBuildingIDs = null; |
||
37 | |||
38 | /** |
||
39 | * @var string $strBeddingIDs |
||
40 | */ |
||
41 | protected $strBeddingIDs = null; |
||
42 | |||
43 | /** |
||
44 | * @var \DateTime $ArrivalDate |
||
45 | */ |
||
46 | protected $ArrivalDate = null; |
||
47 | |||
48 | /** |
||
49 | * @var \DateTime $DepartureDate |
||
50 | */ |
||
51 | protected $DepartureDate = null; |
||
52 | |||
53 | /** |
||
54 | * @var string $strAttributeGroupings |
||
55 | */ |
||
56 | protected $strAttributeGroupings = null; |
||
57 | |||
58 | /** |
||
59 | * @var string $strLocationsGroupings |
||
60 | */ |
||
61 | protected $strLocationsGroupings = null; |
||
62 | |||
63 | /** |
||
64 | * @var InventoryResponse $HotelInventoryResponse |
||
65 | */ |
||
66 | protected $HotelInventoryResponse = null; |
||
67 | |||
68 | /** |
||
69 | * @param int $guid |
||
70 | * @param string $strRoomIDs |
||
71 | * @param string $strRoomTypeIDs |
||
72 | * @param string $strRoomAttributeIDs |
||
73 | * @param string $strRoomLocationIDs |
||
74 | * @param string $strBuildingIDs |
||
75 | * @param string $strBeddingIDs |
||
76 | * @param \DateTime $ArrivalDate |
||
77 | * @param \DateTime $DepartureDate |
||
78 | * @param string $strAttributeGroupings |
||
79 | * @param string $strLocationsGroupings |
||
80 | * @param InventoryResponse $HotelInventoryResponse |
||
81 | */ |
||
82 | public function __construct($guid, $strRoomIDs, $strRoomTypeIDs, $strRoomAttributeIDs, $strRoomLocationIDs, $strBuildingIDs, $strBeddingIDs, \DateTime $ArrivalDate, \DateTime $DepartureDate, $strAttributeGroupings, $strLocationsGroupings, $HotelInventoryResponse) |
||
97 | |||
98 | /** |
||
99 | * @return int |
||
100 | */ |
||
101 | public function getGuid() |
||
105 | |||
106 | /** |
||
107 | * @param int $guid |
||
108 | * @return \Gueststream\PMS\IQWare\API\getAllRoomsAvailabilityForStayFast |
||
109 | */ |
||
110 | public function setGuid($guid) |
||
115 | |||
116 | /** |
||
117 | * @return string |
||
118 | */ |
||
119 | public function getStrRoomIDs() |
||
123 | |||
124 | /** |
||
125 | * @param string $strRoomIDs |
||
126 | * @return \Gueststream\PMS\IQWare\API\getAllRoomsAvailabilityForStayFast |
||
127 | */ |
||
128 | public function setStrRoomIDs($strRoomIDs) |
||
133 | |||
134 | /** |
||
135 | * @return string |
||
136 | */ |
||
137 | public function getStrRoomTypeIDs() |
||
141 | |||
142 | /** |
||
143 | * @param string $strRoomTypeIDs |
||
144 | * @return \Gueststream\PMS\IQWare\API\getAllRoomsAvailabilityForStayFast |
||
145 | */ |
||
146 | public function setStrRoomTypeIDs($strRoomTypeIDs) |
||
151 | |||
152 | /** |
||
153 | * @return string |
||
154 | */ |
||
155 | public function getStrRoomAttributeIDs() |
||
159 | |||
160 | /** |
||
161 | * @param string $strRoomAttributeIDs |
||
162 | * @return \Gueststream\PMS\IQWare\API\getAllRoomsAvailabilityForStayFast |
||
163 | */ |
||
164 | public function setStrRoomAttributeIDs($strRoomAttributeIDs) |
||
169 | |||
170 | /** |
||
171 | * @return string |
||
172 | */ |
||
173 | public function getStrRoomLocationIDs() |
||
177 | |||
178 | /** |
||
179 | * @param string $strRoomLocationIDs |
||
180 | * @return \Gueststream\PMS\IQWare\API\getAllRoomsAvailabilityForStayFast |
||
181 | */ |
||
182 | public function setStrRoomLocationIDs($strRoomLocationIDs) |
||
187 | |||
188 | /** |
||
189 | * @return string |
||
190 | */ |
||
191 | public function getStrBuildingIDs() |
||
195 | |||
196 | /** |
||
197 | * @param string $strBuildingIDs |
||
198 | * @return \Gueststream\PMS\IQWare\API\getAllRoomsAvailabilityForStayFast |
||
199 | */ |
||
200 | public function setStrBuildingIDs($strBuildingIDs) |
||
205 | |||
206 | /** |
||
207 | * @return string |
||
208 | */ |
||
209 | public function getStrBeddingIDs() |
||
213 | |||
214 | /** |
||
215 | * @param string $strBeddingIDs |
||
216 | * @return \Gueststream\PMS\IQWare\API\getAllRoomsAvailabilityForStayFast |
||
217 | */ |
||
218 | public function setStrBeddingIDs($strBeddingIDs) |
||
223 | |||
224 | /** |
||
225 | * @return \DateTime |
||
226 | */ |
||
227 | public function getArrivalDate() |
||
239 | |||
240 | /** |
||
241 | * @param \DateTime $ArrivalDate |
||
242 | * @return \Gueststream\PMS\IQWare\API\getAllRoomsAvailabilityForStayFast |
||
243 | */ |
||
244 | public function setArrivalDate(\DateTime $ArrivalDate) |
||
249 | |||
250 | /** |
||
251 | * @return \DateTime |
||
252 | */ |
||
253 | public function getDepartureDate() |
||
265 | |||
266 | /** |
||
267 | * @param \DateTime $DepartureDate |
||
268 | * @return \Gueststream\PMS\IQWare\API\getAllRoomsAvailabilityForStayFast |
||
269 | */ |
||
270 | public function setDepartureDate(\DateTime $DepartureDate) |
||
275 | |||
276 | /** |
||
277 | * @return string |
||
278 | */ |
||
279 | public function getStrAttributeGroupings() |
||
283 | |||
284 | /** |
||
285 | * @param string $strAttributeGroupings |
||
286 | * @return \Gueststream\PMS\IQWare\API\getAllRoomsAvailabilityForStayFast |
||
287 | */ |
||
288 | public function setStrAttributeGroupings($strAttributeGroupings) |
||
293 | |||
294 | /** |
||
295 | * @return string |
||
296 | */ |
||
297 | public function getStrLocationsGroupings() |
||
301 | |||
302 | /** |
||
303 | * @param string $strLocationsGroupings |
||
304 | * @return \Gueststream\PMS\IQWare\API\getAllRoomsAvailabilityForStayFast |
||
305 | */ |
||
306 | public function setStrLocationsGroupings($strLocationsGroupings) |
||
311 | |||
312 | /** |
||
313 | * @return InventoryResponse |
||
314 | */ |
||
315 | public function getHotelInventoryResponse() |
||
319 | |||
320 | /** |
||
321 | * @param InventoryResponse $HotelInventoryResponse |
||
322 | * @return \Gueststream\PMS\IQWare\API\getAllRoomsAvailabilityForStayFast |
||
323 | */ |
||
324 | public function setHotelInventoryResponse($HotelInventoryResponse) |
||
329 | } |
||
330 |
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.