Complex classes like ExportedRate 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 ExportedRate, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 5 | class ExportedRate |
||
| 6 | { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * @var int $ID_RateCode |
||
| 10 | */ |
||
| 11 | protected $ID_RateCode = null; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var int $ID_RoomType |
||
| 15 | */ |
||
| 16 | protected $ID_RoomType = null; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var \DateTime $aDate |
||
| 20 | */ |
||
| 21 | protected $aDate = null; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var float $simple |
||
| 25 | */ |
||
| 26 | protected $simple = null; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var float $dble |
||
| 30 | */ |
||
| 31 | protected $dble = null; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var float $triple |
||
| 35 | */ |
||
| 36 | protected $triple = null; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var float $quad |
||
| 40 | */ |
||
| 41 | protected $quad = null; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var float $add |
||
| 45 | */ |
||
| 46 | protected $add = null; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @var float $cat1 |
||
| 50 | */ |
||
| 51 | protected $cat1 = null; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @var float $cat2 |
||
| 55 | */ |
||
| 56 | protected $cat2 = null; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @var float $cat3 |
||
| 60 | */ |
||
| 61 | protected $cat3 = null; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @var float $cat4 |
||
| 65 | */ |
||
| 66 | protected $cat4 = null; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @var float $simple_yeild |
||
| 70 | */ |
||
| 71 | protected $simple_yeild = null; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @var float $dble_yeild |
||
| 75 | */ |
||
| 76 | protected $dble_yeild = null; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @var float $triple_yeild |
||
| 80 | */ |
||
| 81 | protected $triple_yeild = null; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @var float $quad_yeild |
||
| 85 | */ |
||
| 86 | protected $quad_yeild = null; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @var float $add_yeild |
||
| 90 | */ |
||
| 91 | protected $add_yeild = null; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @var float $cat1_yeild |
||
| 95 | */ |
||
| 96 | protected $cat1_yeild = null; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @var float $cat2_yeild |
||
| 100 | */ |
||
| 101 | protected $cat2_yeild = null; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @var float $cat3_yeild |
||
| 105 | */ |
||
| 106 | protected $cat3_yeild = null; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @var float $cat4_yeild |
||
| 110 | */ |
||
| 111 | protected $cat4_yeild = null; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @param int $ID_RateCode |
||
| 115 | * @param int $ID_RoomType |
||
| 116 | * @param \DateTime $aDate |
||
| 117 | * @param float $simple |
||
| 118 | * @param float $dble |
||
| 119 | * @param float $triple |
||
| 120 | * @param float $quad |
||
| 121 | * @param float $add |
||
| 122 | * @param float $cat1 |
||
| 123 | * @param float $cat2 |
||
| 124 | * @param float $cat3 |
||
| 125 | * @param float $cat4 |
||
| 126 | * @param float $simple_yeild |
||
| 127 | * @param float $dble_yeild |
||
| 128 | * @param float $triple_yeild |
||
| 129 | * @param float $quad_yeild |
||
| 130 | * @param float $add_yeild |
||
| 131 | * @param float $cat1_yeild |
||
| 132 | * @param float $cat2_yeild |
||
| 133 | * @param float $cat3_yeild |
||
| 134 | * @param float $cat4_yeild |
||
| 135 | */ |
||
| 136 | public function __construct($ID_RateCode, $ID_RoomType, \DateTime $aDate, $simple, $dble, $triple, $quad, $add, $cat1, $cat2, $cat3, $cat4, $simple_yeild, $dble_yeild, $triple_yeild, $quad_yeild, $add_yeild, $cat1_yeild, $cat2_yeild, $cat3_yeild, $cat4_yeild) |
||
| 160 | |||
| 161 | /** |
||
| 162 | * @return int |
||
| 163 | */ |
||
| 164 | public function getID_RateCode() |
||
| 168 | |||
| 169 | /** |
||
| 170 | * @param int $ID_RateCode |
||
| 171 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 172 | */ |
||
| 173 | public function setID_RateCode($ID_RateCode) |
||
| 178 | |||
| 179 | /** |
||
| 180 | * @return int |
||
| 181 | */ |
||
| 182 | public function getID_RoomType() |
||
| 186 | |||
| 187 | /** |
||
| 188 | * @param int $ID_RoomType |
||
| 189 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 190 | */ |
||
| 191 | public function setID_RoomType($ID_RoomType) |
||
| 196 | |||
| 197 | /** |
||
| 198 | * @return \DateTime |
||
| 199 | */ |
||
| 200 | public function getADate() |
||
| 212 | |||
| 213 | /** |
||
| 214 | * @param \DateTime $aDate |
||
| 215 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 216 | */ |
||
| 217 | public function setADate(\DateTime $aDate) |
||
| 222 | |||
| 223 | /** |
||
| 224 | * @return float |
||
| 225 | */ |
||
| 226 | public function getSimple() |
||
| 230 | |||
| 231 | /** |
||
| 232 | * @param float $simple |
||
| 233 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 234 | */ |
||
| 235 | public function setSimple($simple) |
||
| 240 | |||
| 241 | /** |
||
| 242 | * @return float |
||
| 243 | */ |
||
| 244 | public function getDble() |
||
| 248 | |||
| 249 | /** |
||
| 250 | * @param float $dble |
||
| 251 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 252 | */ |
||
| 253 | public function setDble($dble) |
||
| 258 | |||
| 259 | /** |
||
| 260 | * @return float |
||
| 261 | */ |
||
| 262 | public function getTriple() |
||
| 266 | |||
| 267 | /** |
||
| 268 | * @param float $triple |
||
| 269 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 270 | */ |
||
| 271 | public function setTriple($triple) |
||
| 276 | |||
| 277 | /** |
||
| 278 | * @return float |
||
| 279 | */ |
||
| 280 | public function getQuad() |
||
| 284 | |||
| 285 | /** |
||
| 286 | * @param float $quad |
||
| 287 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 288 | */ |
||
| 289 | public function setQuad($quad) |
||
| 294 | |||
| 295 | /** |
||
| 296 | * @return float |
||
| 297 | */ |
||
| 298 | public function getAdd() |
||
| 302 | |||
| 303 | /** |
||
| 304 | * @param float $add |
||
| 305 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 306 | */ |
||
| 307 | public function setAdd($add) |
||
| 312 | |||
| 313 | /** |
||
| 314 | * @return float |
||
| 315 | */ |
||
| 316 | public function getCat1() |
||
| 320 | |||
| 321 | /** |
||
| 322 | * @param float $cat1 |
||
| 323 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 324 | */ |
||
| 325 | public function setCat1($cat1) |
||
| 330 | |||
| 331 | /** |
||
| 332 | * @return float |
||
| 333 | */ |
||
| 334 | public function getCat2() |
||
| 338 | |||
| 339 | /** |
||
| 340 | * @param float $cat2 |
||
| 341 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 342 | */ |
||
| 343 | public function setCat2($cat2) |
||
| 348 | |||
| 349 | /** |
||
| 350 | * @return float |
||
| 351 | */ |
||
| 352 | public function getCat3() |
||
| 356 | |||
| 357 | /** |
||
| 358 | * @param float $cat3 |
||
| 359 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 360 | */ |
||
| 361 | public function setCat3($cat3) |
||
| 366 | |||
| 367 | /** |
||
| 368 | * @return float |
||
| 369 | */ |
||
| 370 | public function getCat4() |
||
| 374 | |||
| 375 | /** |
||
| 376 | * @param float $cat4 |
||
| 377 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 378 | */ |
||
| 379 | public function setCat4($cat4) |
||
| 384 | |||
| 385 | /** |
||
| 386 | * @return float |
||
| 387 | */ |
||
| 388 | public function getSimple_yeild() |
||
| 392 | |||
| 393 | /** |
||
| 394 | * @param float $simple_yeild |
||
| 395 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 396 | */ |
||
| 397 | public function setSimple_yeild($simple_yeild) |
||
| 402 | |||
| 403 | /** |
||
| 404 | * @return float |
||
| 405 | */ |
||
| 406 | public function getDble_yeild() |
||
| 410 | |||
| 411 | /** |
||
| 412 | * @param float $dble_yeild |
||
| 413 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 414 | */ |
||
| 415 | public function setDble_yeild($dble_yeild) |
||
| 420 | |||
| 421 | /** |
||
| 422 | * @return float |
||
| 423 | */ |
||
| 424 | public function getTriple_yeild() |
||
| 428 | |||
| 429 | /** |
||
| 430 | * @param float $triple_yeild |
||
| 431 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 432 | */ |
||
| 433 | public function setTriple_yeild($triple_yeild) |
||
| 438 | |||
| 439 | /** |
||
| 440 | * @return float |
||
| 441 | */ |
||
| 442 | public function getQuad_yeild() |
||
| 446 | |||
| 447 | /** |
||
| 448 | * @param float $quad_yeild |
||
| 449 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 450 | */ |
||
| 451 | public function setQuad_yeild($quad_yeild) |
||
| 456 | |||
| 457 | /** |
||
| 458 | * @return float |
||
| 459 | */ |
||
| 460 | public function getAdd_yeild() |
||
| 464 | |||
| 465 | /** |
||
| 466 | * @param float $add_yeild |
||
| 467 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 468 | */ |
||
| 469 | public function setAdd_yeild($add_yeild) |
||
| 474 | |||
| 475 | /** |
||
| 476 | * @return float |
||
| 477 | */ |
||
| 478 | public function getCat1_yeild() |
||
| 482 | |||
| 483 | /** |
||
| 484 | * @param float $cat1_yeild |
||
| 485 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 486 | */ |
||
| 487 | public function setCat1_yeild($cat1_yeild) |
||
| 492 | |||
| 493 | /** |
||
| 494 | * @return float |
||
| 495 | */ |
||
| 496 | public function getCat2_yeild() |
||
| 500 | |||
| 501 | /** |
||
| 502 | * @param float $cat2_yeild |
||
| 503 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 504 | */ |
||
| 505 | public function setCat2_yeild($cat2_yeild) |
||
| 510 | |||
| 511 | /** |
||
| 512 | * @return float |
||
| 513 | */ |
||
| 514 | public function getCat3_yeild() |
||
| 518 | |||
| 519 | /** |
||
| 520 | * @param float $cat3_yeild |
||
| 521 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 522 | */ |
||
| 523 | public function setCat3_yeild($cat3_yeild) |
||
| 528 | |||
| 529 | /** |
||
| 530 | * @return float |
||
| 531 | */ |
||
| 532 | public function getCat4_yeild() |
||
| 536 | |||
| 537 | /** |
||
| 538 | * @param float $cat4_yeild |
||
| 539 | * @return \Gueststream\PMS\IQWare\API\ExportedRate |
||
| 540 | */ |
||
| 541 | public function setCat4_yeild($cat4_yeild) |
||
| 546 | } |
||
| 547 |
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..