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 getRoomLocations |
|
|
|||
6 | { |
||
7 | |||
8 | /** |
||
9 | * @var int $intGUID |
||
10 | */ |
||
11 | protected $intGUID = null; |
||
12 | |||
13 | /** |
||
14 | * @var int $intRoomTypeID |
||
15 | */ |
||
16 | protected $intRoomTypeID = null; |
||
17 | |||
18 | /** |
||
19 | * @var string $strISOLanguage |
||
20 | */ |
||
21 | protected $strISOLanguage = null; |
||
22 | |||
23 | /** |
||
24 | * @var int $intHotelCurrencyID |
||
25 | */ |
||
26 | protected $intHotelCurrencyID = null; |
||
27 | |||
28 | /** |
||
29 | * @param int $intGUID |
||
30 | * @param int $intRoomTypeID |
||
31 | * @param string $strISOLanguage |
||
32 | * @param int $intHotelCurrencyID |
||
33 | */ |
||
34 | public function __construct($intGUID, $intRoomTypeID, $strISOLanguage, $intHotelCurrencyID) |
||
41 | |||
42 | /** |
||
43 | * @return int |
||
44 | */ |
||
45 | public function getIntGUID() |
||
49 | |||
50 | /** |
||
51 | * @param int $intGUID |
||
52 | * @return \Gueststream\PMS\IQWare\API\getRoomLocations |
||
53 | */ |
||
54 | public function setIntGUID($intGUID) |
||
59 | |||
60 | /** |
||
61 | * @return int |
||
62 | */ |
||
63 | public function getIntRoomTypeID() |
||
67 | |||
68 | /** |
||
69 | * @param int $intRoomTypeID |
||
70 | * @return \Gueststream\PMS\IQWare\API\getRoomLocations |
||
71 | */ |
||
72 | public function setIntRoomTypeID($intRoomTypeID) |
||
77 | |||
78 | /** |
||
79 | * @return string |
||
80 | */ |
||
81 | public function getStrISOLanguage() |
||
85 | |||
86 | /** |
||
87 | * @param string $strISOLanguage |
||
88 | * @return \Gueststream\PMS\IQWare\API\getRoomLocations |
||
89 | */ |
||
90 | public function setStrISOLanguage($strISOLanguage) |
||
95 | |||
96 | /** |
||
97 | * @return int |
||
98 | */ |
||
99 | public function getIntHotelCurrencyID() |
||
103 | |||
104 | /** |
||
105 | * @param int $intHotelCurrencyID |
||
106 | * @return \Gueststream\PMS\IQWare\API\getRoomLocations |
||
107 | */ |
||
108 | public function setIntHotelCurrencyID($intHotelCurrencyID) |
||
113 | } |
||
114 |
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.