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 |
||
38 | class MasterPricerExpertSearch extends BaseMasterPricerMessage |
||
39 | { |
||
40 | |||
41 | /** |
||
42 | * @var mixed |
||
43 | */ |
||
44 | public $globalOptions; |
||
45 | /** |
||
46 | * @var MasterPricer\CustomerRef |
||
47 | */ |
||
48 | public $customerRef; |
||
49 | /** |
||
50 | * @var mixed |
||
51 | */ |
||
52 | public $formOfPaymentByPassenger; |
||
53 | /** |
||
54 | * @var mixed |
||
55 | */ |
||
56 | public $solutionFamily; |
||
57 | /** |
||
58 | * @var mixed[] |
||
59 | */ |
||
60 | public $passengerInfoGrp = []; |
||
61 | /** |
||
62 | * @var MasterPricer\FareFamilies[] |
||
63 | */ |
||
64 | public $fareFamilies = []; |
||
65 | /** |
||
66 | * @var MasterPricer\PriceToBeat |
||
67 | */ |
||
68 | public $priceToBeat; |
||
69 | /** |
||
70 | * @var mixed |
||
71 | */ |
||
72 | public $taxInfo; |
||
73 | /** |
||
74 | * @var MasterPricer\TravelFlightInfo |
||
75 | */ |
||
76 | public $travelFlightInfo; |
||
77 | /** |
||
78 | * @var array |
||
79 | */ |
||
80 | public $valueSearch = []; |
||
81 | /** |
||
82 | * Itinerary |
||
83 | * |
||
84 | * @var MasterPricer\Itinerary[] |
||
85 | */ |
||
86 | public $itinerary = []; |
||
87 | /** |
||
88 | * @var mixed |
||
89 | */ |
||
90 | public $ticketChangeInfo; |
||
91 | /** |
||
92 | * @var mixed |
||
93 | */ |
||
94 | public $combinationFareFamilies; |
||
95 | /** |
||
96 | * @var MasterPricer\FeeOption[] |
||
97 | */ |
||
98 | public $feeOption; |
||
99 | /** |
||
100 | * @var MasterPricer\OfficeIdDetails[] |
||
101 | */ |
||
102 | public $officeIdDetails; |
||
103 | |||
104 | /** |
||
105 | * MasterPricerExpertSearch constructor. |
||
106 | * |
||
107 | * @param FareMasterPricerExSearch|FareMasterPricerCalendarOptions|TicketAtcShopperMpExSearchOptions|null $options |
||
108 | */ |
||
109 | 132 | public function __construct($options = null) |
|
115 | |||
116 | /** |
||
117 | * @param FareMasterPricerExSearch|FareMasterPricerCalendarOptions|TicketAtcShopperMpExSearchOptions $options |
||
118 | */ |
||
119 | 132 | protected function loadOptions($options) |
|
175 | |||
176 | /** |
||
177 | * @param string $officeId |
||
178 | */ |
||
179 | 4 | protected function loadOfficeId($officeId) |
|
183 | |||
184 | /** |
||
185 | * @param MPItinerary $opt |
||
186 | * @param int $counter BYREF |
||
187 | */ |
||
188 | 120 | protected function loadItinerary($opt, &$counter) |
|
231 | |||
232 | /** |
||
233 | * @param MPFareFamily[] $fareFamilies |
||
234 | */ |
||
235 | 132 | protected function loadFareFamilies($fareFamilies) |
|
241 | |||
242 | /** |
||
243 | * Load Customer references |
||
244 | * |
||
245 | * @param string $dkNumber |
||
246 | */ |
||
247 | 132 | View Code Duplication | protected function loadCustomerRefs($dkNumber) |
257 | |||
258 | 132 | private function loadFeeOptions($feeOptions) |
|
266 | } |
||
267 |
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.