Complex classes like GetAvailRatesAndRoomNumbers 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 GetAvailRatesAndRoomNumbers, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 5 | class GetAvailRatesAndRoomNumbers |
||
| 6 | { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * @var ArrayOfInt $iGuids |
||
| 10 | */ |
||
| 11 | protected $iGuids = null; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var \DateTime $dtArrivalDate |
||
| 15 | */ |
||
| 16 | protected $dtArrivalDate = null; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var \DateTime $dtDepartureDate |
||
| 20 | */ |
||
| 21 | protected $dtDepartureDate = null; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var int $intGuestCount |
||
| 25 | */ |
||
| 26 | protected $intGuestCount = null; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var string $strChildrens |
||
| 30 | */ |
||
| 31 | protected $strChildrens = null; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var string $strISOLanguageCode |
||
| 35 | */ |
||
| 36 | protected $strISOLanguageCode = null; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var int $intID_AccommodationType |
||
| 40 | */ |
||
| 41 | protected $intID_AccommodationType = null; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var int $intRoomQty |
||
| 45 | */ |
||
| 46 | protected $intRoomQty = null; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @var string $strListOfPromoRates |
||
| 50 | */ |
||
| 51 | protected $strListOfPromoRates = null; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @var boolean $IsPromoByRate |
||
| 55 | */ |
||
| 56 | protected $IsPromoByRate = null; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @var int $intRateSpecial |
||
| 60 | */ |
||
| 61 | protected $intRateSpecial = null; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @var string $strRateCodes |
||
| 65 | */ |
||
| 66 | protected $strRateCodes = null; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @var string $strRoomTypes |
||
| 70 | */ |
||
| 71 | protected $strRoomTypes = null; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @var string $strRoomAttributeIDs |
||
| 75 | */ |
||
| 76 | protected $strRoomAttributeIDs = null; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @var string $strRoomLocationIDs |
||
| 80 | */ |
||
| 81 | protected $strRoomLocationIDs = null; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @var string $PushID |
||
| 85 | */ |
||
| 86 | protected $PushID = null; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @var IAB2BMode $BackToBackMode |
||
| 90 | */ |
||
| 91 | protected $BackToBackMode = null; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @var boolean $IsClusterVersion |
||
| 95 | */ |
||
| 96 | protected $IsClusterVersion = null; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @param ArrayOfInt $iGuids |
||
| 100 | * @param \DateTime $dtArrivalDate |
||
| 101 | * @param \DateTime $dtDepartureDate |
||
| 102 | * @param int $intGuestCount |
||
| 103 | * @param string $strChildrens |
||
| 104 | * @param string $strISOLanguageCode |
||
| 105 | * @param int $intID_AccommodationType |
||
| 106 | * @param int $intRoomQty |
||
| 107 | * @param string $strListOfPromoRates |
||
| 108 | * @param boolean $IsPromoByRate |
||
| 109 | * @param int $intRateSpecial |
||
| 110 | * @param string $strRateCodes |
||
| 111 | * @param string $strRoomTypes |
||
| 112 | * @param string $strRoomAttributeIDs |
||
| 113 | * @param string $strRoomLocationIDs |
||
| 114 | * @param string $PushID |
||
| 115 | * @param IAB2BMode $BackToBackMode |
||
| 116 | * @param boolean $IsClusterVersion |
||
| 117 | */ |
||
| 118 | public function __construct($iGuids, \DateTime $dtArrivalDate, \DateTime $dtDepartureDate, $intGuestCount, $strChildrens, $strISOLanguageCode, $intID_AccommodationType, $intRoomQty, $strListOfPromoRates, $IsPromoByRate, $intRateSpecial, $strRateCodes, $strRoomTypes, $strRoomAttributeIDs, $strRoomLocationIDs, $PushID, $BackToBackMode, $IsClusterVersion) |
||
| 139 | |||
| 140 | /** |
||
| 141 | * @return ArrayOfInt |
||
| 142 | */ |
||
| 143 | public function getIGuids() |
||
| 147 | |||
| 148 | /** |
||
| 149 | * @param ArrayOfInt $iGuids |
||
| 150 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 151 | */ |
||
| 152 | public function setIGuids($iGuids) |
||
| 157 | |||
| 158 | /** |
||
| 159 | * @return \DateTime |
||
| 160 | */ |
||
| 161 | public function getDtArrivalDate() |
||
| 173 | |||
| 174 | /** |
||
| 175 | * @param \DateTime $dtArrivalDate |
||
| 176 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 177 | */ |
||
| 178 | public function setDtArrivalDate(\DateTime $dtArrivalDate) |
||
| 183 | |||
| 184 | /** |
||
| 185 | * @return \DateTime |
||
| 186 | */ |
||
| 187 | public function getDtDepartureDate() |
||
| 199 | |||
| 200 | /** |
||
| 201 | * @param \DateTime $dtDepartureDate |
||
| 202 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 203 | */ |
||
| 204 | public function setDtDepartureDate(\DateTime $dtDepartureDate) |
||
| 209 | |||
| 210 | /** |
||
| 211 | * @return int |
||
| 212 | */ |
||
| 213 | public function getIntGuestCount() |
||
| 217 | |||
| 218 | /** |
||
| 219 | * @param int $intGuestCount |
||
| 220 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 221 | */ |
||
| 222 | public function setIntGuestCount($intGuestCount) |
||
| 227 | |||
| 228 | /** |
||
| 229 | * @return string |
||
| 230 | */ |
||
| 231 | public function getStrChildrens() |
||
| 235 | |||
| 236 | /** |
||
| 237 | * @param string $strChildrens |
||
| 238 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 239 | */ |
||
| 240 | public function setStrChildrens($strChildrens) |
||
| 245 | |||
| 246 | /** |
||
| 247 | * @return string |
||
| 248 | */ |
||
| 249 | public function getStrISOLanguageCode() |
||
| 253 | |||
| 254 | /** |
||
| 255 | * @param string $strISOLanguageCode |
||
| 256 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 257 | */ |
||
| 258 | public function setStrISOLanguageCode($strISOLanguageCode) |
||
| 263 | |||
| 264 | /** |
||
| 265 | * @return int |
||
| 266 | */ |
||
| 267 | public function getIntID_AccommodationType() |
||
| 271 | |||
| 272 | /** |
||
| 273 | * @param int $intID_AccommodationType |
||
| 274 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 275 | */ |
||
| 276 | public function setIntID_AccommodationType($intID_AccommodationType) |
||
| 281 | |||
| 282 | /** |
||
| 283 | * @return int |
||
| 284 | */ |
||
| 285 | public function getIntRoomQty() |
||
| 289 | |||
| 290 | /** |
||
| 291 | * @param int $intRoomQty |
||
| 292 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 293 | */ |
||
| 294 | public function setIntRoomQty($intRoomQty) |
||
| 299 | |||
| 300 | /** |
||
| 301 | * @return string |
||
| 302 | */ |
||
| 303 | public function getStrListOfPromoRates() |
||
| 307 | |||
| 308 | /** |
||
| 309 | * @param string $strListOfPromoRates |
||
| 310 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 311 | */ |
||
| 312 | public function setStrListOfPromoRates($strListOfPromoRates) |
||
| 317 | |||
| 318 | /** |
||
| 319 | * @return boolean |
||
| 320 | */ |
||
| 321 | public function getIsPromoByRate() |
||
| 325 | |||
| 326 | /** |
||
| 327 | * @param boolean $IsPromoByRate |
||
| 328 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 329 | */ |
||
| 330 | public function setIsPromoByRate($IsPromoByRate) |
||
| 335 | |||
| 336 | /** |
||
| 337 | * @return int |
||
| 338 | */ |
||
| 339 | public function getIntRateSpecial() |
||
| 343 | |||
| 344 | /** |
||
| 345 | * @param int $intRateSpecial |
||
| 346 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 347 | */ |
||
| 348 | public function setIntRateSpecial($intRateSpecial) |
||
| 353 | |||
| 354 | /** |
||
| 355 | * @return string |
||
| 356 | */ |
||
| 357 | public function getStrRateCodes() |
||
| 361 | |||
| 362 | /** |
||
| 363 | * @param string $strRateCodes |
||
| 364 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 365 | */ |
||
| 366 | public function setStrRateCodes($strRateCodes) |
||
| 371 | |||
| 372 | /** |
||
| 373 | * @return string |
||
| 374 | */ |
||
| 375 | public function getStrRoomTypes() |
||
| 379 | |||
| 380 | /** |
||
| 381 | * @param string $strRoomTypes |
||
| 382 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 383 | */ |
||
| 384 | public function setStrRoomTypes($strRoomTypes) |
||
| 389 | |||
| 390 | /** |
||
| 391 | * @return string |
||
| 392 | */ |
||
| 393 | public function getStrRoomAttributeIDs() |
||
| 397 | |||
| 398 | /** |
||
| 399 | * @param string $strRoomAttributeIDs |
||
| 400 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 401 | */ |
||
| 402 | public function setStrRoomAttributeIDs($strRoomAttributeIDs) |
||
| 407 | |||
| 408 | /** |
||
| 409 | * @return string |
||
| 410 | */ |
||
| 411 | public function getStrRoomLocationIDs() |
||
| 415 | |||
| 416 | /** |
||
| 417 | * @param string $strRoomLocationIDs |
||
| 418 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 419 | */ |
||
| 420 | public function setStrRoomLocationIDs($strRoomLocationIDs) |
||
| 425 | |||
| 426 | /** |
||
| 427 | * @return string |
||
| 428 | */ |
||
| 429 | public function getPushID() |
||
| 433 | |||
| 434 | /** |
||
| 435 | * @param string $PushID |
||
| 436 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 437 | */ |
||
| 438 | public function setPushID($PushID) |
||
| 443 | |||
| 444 | /** |
||
| 445 | * @return IAB2BMode |
||
| 446 | */ |
||
| 447 | public function getBackToBackMode() |
||
| 451 | |||
| 452 | /** |
||
| 453 | * @param IAB2BMode $BackToBackMode |
||
| 454 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 455 | */ |
||
| 456 | public function setBackToBackMode($BackToBackMode) |
||
| 461 | |||
| 462 | /** |
||
| 463 | * @return boolean |
||
| 464 | */ |
||
| 465 | public function getIsClusterVersion() |
||
| 469 | |||
| 470 | /** |
||
| 471 | * @param boolean $IsClusterVersion |
||
| 472 | * @return \Gueststream\PMS\IQWare\API\GetAvailRatesAndRoomNumbers |
||
| 473 | */ |
||
| 474 | public function setIsClusterVersion($IsClusterVersion) |
||
| 479 | } |
||
| 480 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..