Complex classes like PricePNRWithBookingClass12 often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use PricePNRWithBookingClass12, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 50 | class PricePNRWithBookingClass12 extends BaseWsMessage |
||
| 51 | { |
||
| 52 | public $pnrLocatorData; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @var PricePnr12\PaxSegReference |
||
| 56 | */ |
||
| 57 | public $paxSegReference; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @var PricePnr12\OverrideInformation |
||
| 61 | */ |
||
| 62 | public $overrideInformation; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var PricePnr12\DateOverride |
||
| 66 | */ |
||
| 67 | public $dateOverride; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @var PricePnr12\ValidatingCarrier |
||
| 71 | */ |
||
| 72 | public $validatingCarrier; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @var PricePnr12\CityOverride |
||
| 76 | */ |
||
| 77 | public $cityOverride; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @var PricePnr12\CurrencyOverride |
||
| 81 | */ |
||
| 82 | public $currencyOverride; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @var PricePnr12\TaxDetails[] |
||
| 86 | */ |
||
| 87 | public $taxDetails = []; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @var PricePnr12\DiscountInformation[] |
||
| 91 | */ |
||
| 92 | public $discountInformation = []; |
||
| 93 | /** |
||
| 94 | * @var PricePnr12\PricingFareBase[] |
||
| 95 | */ |
||
| 96 | public $pricingFareBase = []; |
||
| 97 | |||
| 98 | public $flightInformation; |
||
| 99 | |||
| 100 | public $openSegmentsInformation; |
||
| 101 | |||
| 102 | public $bookingClassSelection; |
||
| 103 | |||
| 104 | public $fopInformation; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @var CarrierAgreements |
||
| 108 | */ |
||
| 109 | public $carrierAgreements; |
||
| 110 | |||
| 111 | /** |
||
| 112 | * @var FrequentFlyerInformation |
||
| 113 | */ |
||
| 114 | public $frequentFlyerInformation; |
||
| 115 | |||
| 116 | public $instantPricingOption; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * PricePNRWithBookingClass12 constructor. |
||
| 120 | * |
||
| 121 | * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt|null $options |
||
| 122 | */ |
||
| 123 | 92 | public function __construct($options) |
|
| 131 | |||
| 132 | /** |
||
| 133 | * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
||
| 134 | */ |
||
| 135 | 92 | protected function loadPricingOptions($options) |
|
| 157 | |||
| 158 | /** |
||
| 159 | * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
||
| 160 | * @throws OptionNotSupportedException |
||
| 161 | */ |
||
| 162 | 92 | protected function checkUnsupportedOptions($options) |
|
| 180 | |||
| 181 | /** |
||
| 182 | * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
||
| 183 | */ |
||
| 184 | 80 | protected function loadOverrideOptionsAndCorpFares($options) |
|
| 219 | |||
| 220 | /** |
||
| 221 | * @param string|null $currencyOverride |
||
| 222 | */ |
||
| 223 | 80 | protected function loadCurrencyOverride($currencyOverride) |
|
| 229 | |||
| 230 | /** |
||
| 231 | * Convert new codes (Price PNR version 13+) to old format |
||
| 232 | * |
||
| 233 | * @param string $optionsTicketType |
||
| 234 | * @return string|null |
||
| 235 | */ |
||
| 236 | 4 | protected function convertTicketType($optionsTicketType) |
|
| 252 | |||
| 253 | /** |
||
| 254 | * @param string[] $corporateUniFares |
||
| 255 | */ |
||
| 256 | 8 | protected function loadCorporateUniFares($corporateUniFares) |
|
| 265 | |||
| 266 | /** |
||
| 267 | * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
||
| 268 | */ |
||
| 269 | 80 | protected function loadOverrideLocations($options) |
|
| 288 | |||
| 289 | /** |
||
| 290 | * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
||
| 291 | */ |
||
| 292 | 80 | protected function loadValidatingCarrier($options) |
|
| 298 | |||
| 299 | /** |
||
| 300 | * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
||
| 301 | * |
||
| 302 | */ |
||
| 303 | 80 | protected function loadFareBasis($options) |
|
| 312 | |||
| 313 | /** |
||
| 314 | * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
||
| 315 | */ |
||
| 316 | 80 | protected function loadTaxOptions($options) |
|
| 326 | |||
| 327 | /** |
||
| 328 | * @param string[] $paxDiscountCodes |
||
| 329 | * @param PaxSegRef[] $refs |
||
| 330 | */ |
||
| 331 | 80 | protected function loadPaxDiscount($paxDiscountCodes, $refs) |
|
| 341 | |||
| 342 | /** |
||
| 343 | * @param PaxSegRef[] $references |
||
| 344 | */ |
||
| 345 | 80 | protected function loadReferences($references) |
|
| 351 | |||
| 352 | /** |
||
| 353 | * @param \DateTime|null $pastDate |
||
| 354 | */ |
||
| 355 | 80 | protected function loadPastDate($pastDate) |
|
| 361 | } |
||
| 362 |