Complex classes like RequiredDeposit 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 RequiredDeposit, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 5 | class RequiredDeposit |
||
| 6 | { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * @var \DateTime $ADate1 |
||
| 10 | */ |
||
| 11 | protected $ADate1 = null; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var int $DateType1 |
||
| 15 | */ |
||
| 16 | protected $DateType1 = null; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var float $LevelAmount1 |
||
| 20 | */ |
||
| 21 | protected $LevelAmount1 = null; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var int $StatusLevel1 |
||
| 25 | */ |
||
| 26 | protected $StatusLevel1 = null; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var int $NbDaysDeposit1 |
||
| 30 | */ |
||
| 31 | protected $NbDaysDeposit1 = null; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var int $DepositType1 |
||
| 35 | */ |
||
| 36 | protected $DepositType1 = null; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var \DateTime $ADate2 |
||
| 40 | */ |
||
| 41 | protected $ADate2 = null; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var int $DateType2 |
||
| 45 | */ |
||
| 46 | protected $DateType2 = null; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @var float $LevelAmount2 |
||
| 50 | */ |
||
| 51 | protected $LevelAmount2 = null; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @var int $StatusLevel2 |
||
| 55 | */ |
||
| 56 | protected $StatusLevel2 = null; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @var int $NbDaysDeposit2 |
||
| 60 | */ |
||
| 61 | protected $NbDaysDeposit2 = null; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @var int $DepositType2 |
||
| 65 | */ |
||
| 66 | protected $DepositType2 = null; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @var \DateTime $ADate3 |
||
| 70 | */ |
||
| 71 | protected $ADate3 = null; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @var int $DateType3 |
||
| 75 | */ |
||
| 76 | protected $DateType3 = null; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @var float $LevelAmount3 |
||
| 80 | */ |
||
| 81 | protected $LevelAmount3 = null; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @var int $StatusLevel3 |
||
| 85 | */ |
||
| 86 | protected $StatusLevel3 = null; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @var int $NbDaysDeposit3 |
||
| 90 | */ |
||
| 91 | protected $NbDaysDeposit3 = null; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @var int $DepositType3 |
||
| 95 | */ |
||
| 96 | protected $DepositType3 = null; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @var string $CancelPolitics |
||
| 100 | */ |
||
| 101 | protected $CancelPolitics = null; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @var string $SeasonName |
||
| 105 | */ |
||
| 106 | protected $SeasonName = null; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @var float $TotStayBDGlobal |
||
| 110 | */ |
||
| 111 | protected $TotStayBDGlobal = null; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @var float $TotStayBD1Global |
||
| 115 | */ |
||
| 116 | protected $TotStayBD1Global = null; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @param \DateTime $ADate1 |
||
| 120 | * @param int $DateType1 |
||
| 121 | * @param float $LevelAmount1 |
||
| 122 | * @param int $StatusLevel1 |
||
| 123 | * @param int $NbDaysDeposit1 |
||
| 124 | * @param int $DepositType1 |
||
| 125 | * @param \DateTime $ADate2 |
||
| 126 | * @param int $DateType2 |
||
| 127 | * @param float $LevelAmount2 |
||
| 128 | * @param int $StatusLevel2 |
||
| 129 | * @param int $NbDaysDeposit2 |
||
| 130 | * @param int $DepositType2 |
||
| 131 | * @param \DateTime $ADate3 |
||
| 132 | * @param int $DateType3 |
||
| 133 | * @param float $LevelAmount3 |
||
| 134 | * @param int $StatusLevel3 |
||
| 135 | * @param int $NbDaysDeposit3 |
||
| 136 | * @param int $DepositType3 |
||
| 137 | * @param float $TotStayBDGlobal |
||
| 138 | * @param float $TotStayBD1Global |
||
| 139 | */ |
||
| 140 | public function __construct(\DateTime $ADate1, $DateType1, $LevelAmount1, $StatusLevel1, $NbDaysDeposit1, $DepositType1, \DateTime $ADate2, $DateType2, $LevelAmount2, $StatusLevel2, $NbDaysDeposit2, $DepositType2, \DateTime $ADate3, $DateType3, $LevelAmount3, $StatusLevel3, $NbDaysDeposit3, $DepositType3, $TotStayBDGlobal, $TotStayBD1Global) |
||
| 163 | |||
| 164 | /** |
||
| 165 | * @return \DateTime |
||
| 166 | */ |
||
| 167 | public function getADate1() |
||
| 179 | |||
| 180 | /** |
||
| 181 | * @param \DateTime $ADate1 |
||
| 182 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 183 | */ |
||
| 184 | public function setADate1(\DateTime $ADate1) |
||
| 189 | |||
| 190 | /** |
||
| 191 | * @return int |
||
| 192 | */ |
||
| 193 | public function getDateType1() |
||
| 197 | |||
| 198 | /** |
||
| 199 | * @param int $DateType1 |
||
| 200 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 201 | */ |
||
| 202 | public function setDateType1($DateType1) |
||
| 207 | |||
| 208 | /** |
||
| 209 | * @return float |
||
| 210 | */ |
||
| 211 | public function getLevelAmount1() |
||
| 215 | |||
| 216 | /** |
||
| 217 | * @param float $LevelAmount1 |
||
| 218 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 219 | */ |
||
| 220 | public function setLevelAmount1($LevelAmount1) |
||
| 225 | |||
| 226 | /** |
||
| 227 | * @return int |
||
| 228 | */ |
||
| 229 | public function getStatusLevel1() |
||
| 233 | |||
| 234 | /** |
||
| 235 | * @param int $StatusLevel1 |
||
| 236 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 237 | */ |
||
| 238 | public function setStatusLevel1($StatusLevel1) |
||
| 243 | |||
| 244 | /** |
||
| 245 | * @return int |
||
| 246 | */ |
||
| 247 | public function getNbDaysDeposit1() |
||
| 251 | |||
| 252 | /** |
||
| 253 | * @param int $NbDaysDeposit1 |
||
| 254 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 255 | */ |
||
| 256 | public function setNbDaysDeposit1($NbDaysDeposit1) |
||
| 261 | |||
| 262 | /** |
||
| 263 | * @return int |
||
| 264 | */ |
||
| 265 | public function getDepositType1() |
||
| 269 | |||
| 270 | /** |
||
| 271 | * @param int $DepositType1 |
||
| 272 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 273 | */ |
||
| 274 | public function setDepositType1($DepositType1) |
||
| 279 | |||
| 280 | /** |
||
| 281 | * @return \DateTime |
||
| 282 | */ |
||
| 283 | public function getADate2() |
||
| 295 | |||
| 296 | /** |
||
| 297 | * @param \DateTime $ADate2 |
||
| 298 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 299 | */ |
||
| 300 | public function setADate2(\DateTime $ADate2) |
||
| 305 | |||
| 306 | /** |
||
| 307 | * @return int |
||
| 308 | */ |
||
| 309 | public function getDateType2() |
||
| 313 | |||
| 314 | /** |
||
| 315 | * @param int $DateType2 |
||
| 316 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 317 | */ |
||
| 318 | public function setDateType2($DateType2) |
||
| 323 | |||
| 324 | /** |
||
| 325 | * @return float |
||
| 326 | */ |
||
| 327 | public function getLevelAmount2() |
||
| 331 | |||
| 332 | /** |
||
| 333 | * @param float $LevelAmount2 |
||
| 334 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 335 | */ |
||
| 336 | public function setLevelAmount2($LevelAmount2) |
||
| 341 | |||
| 342 | /** |
||
| 343 | * @return int |
||
| 344 | */ |
||
| 345 | public function getStatusLevel2() |
||
| 349 | |||
| 350 | /** |
||
| 351 | * @param int $StatusLevel2 |
||
| 352 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 353 | */ |
||
| 354 | public function setStatusLevel2($StatusLevel2) |
||
| 359 | |||
| 360 | /** |
||
| 361 | * @return int |
||
| 362 | */ |
||
| 363 | public function getNbDaysDeposit2() |
||
| 367 | |||
| 368 | /** |
||
| 369 | * @param int $NbDaysDeposit2 |
||
| 370 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 371 | */ |
||
| 372 | public function setNbDaysDeposit2($NbDaysDeposit2) |
||
| 377 | |||
| 378 | /** |
||
| 379 | * @return int |
||
| 380 | */ |
||
| 381 | public function getDepositType2() |
||
| 385 | |||
| 386 | /** |
||
| 387 | * @param int $DepositType2 |
||
| 388 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 389 | */ |
||
| 390 | public function setDepositType2($DepositType2) |
||
| 395 | |||
| 396 | /** |
||
| 397 | * @return \DateTime |
||
| 398 | */ |
||
| 399 | public function getADate3() |
||
| 411 | |||
| 412 | /** |
||
| 413 | * @param \DateTime $ADate3 |
||
| 414 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 415 | */ |
||
| 416 | public function setADate3(\DateTime $ADate3) |
||
| 421 | |||
| 422 | /** |
||
| 423 | * @return int |
||
| 424 | */ |
||
| 425 | public function getDateType3() |
||
| 429 | |||
| 430 | /** |
||
| 431 | * @param int $DateType3 |
||
| 432 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 433 | */ |
||
| 434 | public function setDateType3($DateType3) |
||
| 439 | |||
| 440 | /** |
||
| 441 | * @return float |
||
| 442 | */ |
||
| 443 | public function getLevelAmount3() |
||
| 447 | |||
| 448 | /** |
||
| 449 | * @param float $LevelAmount3 |
||
| 450 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 451 | */ |
||
| 452 | public function setLevelAmount3($LevelAmount3) |
||
| 457 | |||
| 458 | /** |
||
| 459 | * @return int |
||
| 460 | */ |
||
| 461 | public function getStatusLevel3() |
||
| 465 | |||
| 466 | /** |
||
| 467 | * @param int $StatusLevel3 |
||
| 468 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 469 | */ |
||
| 470 | public function setStatusLevel3($StatusLevel3) |
||
| 475 | |||
| 476 | /** |
||
| 477 | * @return int |
||
| 478 | */ |
||
| 479 | public function getNbDaysDeposit3() |
||
| 483 | |||
| 484 | /** |
||
| 485 | * @param int $NbDaysDeposit3 |
||
| 486 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 487 | */ |
||
| 488 | public function setNbDaysDeposit3($NbDaysDeposit3) |
||
| 493 | |||
| 494 | /** |
||
| 495 | * @return int |
||
| 496 | */ |
||
| 497 | public function getDepositType3() |
||
| 501 | |||
| 502 | /** |
||
| 503 | * @param int $DepositType3 |
||
| 504 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 505 | */ |
||
| 506 | public function setDepositType3($DepositType3) |
||
| 511 | |||
| 512 | /** |
||
| 513 | * @return string |
||
| 514 | */ |
||
| 515 | public function getCancelPolitics() |
||
| 519 | |||
| 520 | /** |
||
| 521 | * @param string $CancelPolitics |
||
| 522 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 523 | */ |
||
| 524 | public function setCancelPolitics($CancelPolitics) |
||
| 529 | |||
| 530 | /** |
||
| 531 | * @return string |
||
| 532 | */ |
||
| 533 | public function getSeasonName() |
||
| 537 | |||
| 538 | /** |
||
| 539 | * @param string $SeasonName |
||
| 540 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 541 | */ |
||
| 542 | public function setSeasonName($SeasonName) |
||
| 547 | |||
| 548 | /** |
||
| 549 | * @return float |
||
| 550 | */ |
||
| 551 | public function getTotStayBDGlobal() |
||
| 555 | |||
| 556 | /** |
||
| 557 | * @param float $TotStayBDGlobal |
||
| 558 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 559 | */ |
||
| 560 | public function setTotStayBDGlobal($TotStayBDGlobal) |
||
| 565 | |||
| 566 | /** |
||
| 567 | * @return float |
||
| 568 | */ |
||
| 569 | public function getTotStayBD1Global() |
||
| 573 | |||
| 574 | /** |
||
| 575 | * @param float $TotStayBD1Global |
||
| 576 | * @return \Gueststream\PMS\IQWare\API\RequiredDeposit |
||
| 577 | */ |
||
| 578 | public function setTotStayBD1Global($TotStayBD1Global) |
||
| 583 | } |
||
| 584 |
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..