Complex classes like ProtobasePostResult 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 ProtobasePostResult, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 5 | class ProtobasePostResult |
||
| 6 | { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * @var string $MaskedPan |
||
| 10 | */ |
||
| 11 | protected $MaskedPan = null; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var int $ID_CreditCard |
||
| 15 | */ |
||
| 16 | protected $ID_CreditCard = null; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var string $VaultResultToken |
||
| 20 | */ |
||
| 21 | protected $VaultResultToken = null; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var string $VaultResultMessage |
||
| 25 | */ |
||
| 26 | protected $VaultResultMessage = null; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var string $ApprovalCode |
||
| 30 | */ |
||
| 31 | protected $ApprovalCode = null; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var string $HostResponseCode |
||
| 35 | */ |
||
| 36 | protected $HostResponseCode = null; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var string $HostResponseMessage |
||
| 40 | */ |
||
| 41 | protected $HostResponseMessage = null; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var int $ProtobaseResponseCode |
||
| 45 | */ |
||
| 46 | protected $ProtobaseResponseCode = null; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @var string $ProtobaseResponseMessage |
||
| 50 | */ |
||
| 51 | protected $ProtobaseResponseMessage = null; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @var string $CardType |
||
| 55 | */ |
||
| 56 | protected $CardType = null; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @var string $CardName |
||
| 60 | */ |
||
| 61 | protected $CardName = null; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @var string $MerchantNumber |
||
| 65 | */ |
||
| 66 | protected $MerchantNumber = null; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @var string $HostReferenceNumber |
||
| 70 | */ |
||
| 71 | protected $HostReferenceNumber = null; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @var string $IQWareErrorMessage |
||
| 75 | */ |
||
| 76 | protected $IQWareErrorMessage = null; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @var int $AccountID |
||
| 80 | */ |
||
| 81 | protected $AccountID = null; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @var int $AccountNo |
||
| 85 | */ |
||
| 86 | protected $AccountNo = null; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @var string $AccountName |
||
| 90 | */ |
||
| 91 | protected $AccountName = null; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @var \DateTime $TransactionDateTime |
||
| 95 | */ |
||
| 96 | protected $TransactionDateTime = null; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @var int $ItemCode |
||
| 100 | */ |
||
| 101 | protected $ItemCode = null; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @var string $ItemText |
||
| 105 | */ |
||
| 106 | protected $ItemText = null; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @var int $ReferenceNumber |
||
| 110 | */ |
||
| 111 | protected $ReferenceNumber = null; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @param int $ID_CreditCard |
||
| 115 | * @param int $ProtobaseResponseCode |
||
| 116 | * @param int $AccountID |
||
| 117 | * @param int $AccountNo |
||
| 118 | * @param \DateTime $TransactionDateTime |
||
| 119 | * @param int $ItemCode |
||
| 120 | * @param int $ReferenceNumber |
||
| 121 | */ |
||
| 122 | public function __construct($ID_CreditCard, $ProtobaseResponseCode, $AccountID, $AccountNo, \DateTime $TransactionDateTime, $ItemCode, $ReferenceNumber) |
||
| 132 | |||
| 133 | /** |
||
| 134 | * @return string |
||
| 135 | */ |
||
| 136 | public function getMaskedPan() |
||
| 140 | |||
| 141 | /** |
||
| 142 | * @param string $MaskedPan |
||
| 143 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 144 | */ |
||
| 145 | public function setMaskedPan($MaskedPan) |
||
| 150 | |||
| 151 | /** |
||
| 152 | * @return int |
||
| 153 | */ |
||
| 154 | public function getID_CreditCard() |
||
| 158 | |||
| 159 | /** |
||
| 160 | * @param int $ID_CreditCard |
||
| 161 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 162 | */ |
||
| 163 | public function setID_CreditCard($ID_CreditCard) |
||
| 168 | |||
| 169 | /** |
||
| 170 | * @return string |
||
| 171 | */ |
||
| 172 | public function getVaultResultToken() |
||
| 176 | |||
| 177 | /** |
||
| 178 | * @param string $VaultResultToken |
||
| 179 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 180 | */ |
||
| 181 | public function setVaultResultToken($VaultResultToken) |
||
| 186 | |||
| 187 | /** |
||
| 188 | * @return string |
||
| 189 | */ |
||
| 190 | public function getVaultResultMessage() |
||
| 194 | |||
| 195 | /** |
||
| 196 | * @param string $VaultResultMessage |
||
| 197 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 198 | */ |
||
| 199 | public function setVaultResultMessage($VaultResultMessage) |
||
| 204 | |||
| 205 | /** |
||
| 206 | * @return string |
||
| 207 | */ |
||
| 208 | public function getApprovalCode() |
||
| 212 | |||
| 213 | /** |
||
| 214 | * @param string $ApprovalCode |
||
| 215 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 216 | */ |
||
| 217 | public function setApprovalCode($ApprovalCode) |
||
| 222 | |||
| 223 | /** |
||
| 224 | * @return string |
||
| 225 | */ |
||
| 226 | public function getHostResponseCode() |
||
| 230 | |||
| 231 | /** |
||
| 232 | * @param string $HostResponseCode |
||
| 233 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 234 | */ |
||
| 235 | public function setHostResponseCode($HostResponseCode) |
||
| 240 | |||
| 241 | /** |
||
| 242 | * @return string |
||
| 243 | */ |
||
| 244 | public function getHostResponseMessage() |
||
| 248 | |||
| 249 | /** |
||
| 250 | * @param string $HostResponseMessage |
||
| 251 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 252 | */ |
||
| 253 | public function setHostResponseMessage($HostResponseMessage) |
||
| 258 | |||
| 259 | /** |
||
| 260 | * @return int |
||
| 261 | */ |
||
| 262 | public function getProtobaseResponseCode() |
||
| 266 | |||
| 267 | /** |
||
| 268 | * @param int $ProtobaseResponseCode |
||
| 269 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 270 | */ |
||
| 271 | public function setProtobaseResponseCode($ProtobaseResponseCode) |
||
| 276 | |||
| 277 | /** |
||
| 278 | * @return string |
||
| 279 | */ |
||
| 280 | public function getProtobaseResponseMessage() |
||
| 284 | |||
| 285 | /** |
||
| 286 | * @param string $ProtobaseResponseMessage |
||
| 287 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 288 | */ |
||
| 289 | public function setProtobaseResponseMessage($ProtobaseResponseMessage) |
||
| 294 | |||
| 295 | /** |
||
| 296 | * @return string |
||
| 297 | */ |
||
| 298 | public function getCardType() |
||
| 302 | |||
| 303 | /** |
||
| 304 | * @param string $CardType |
||
| 305 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 306 | */ |
||
| 307 | public function setCardType($CardType) |
||
| 312 | |||
| 313 | /** |
||
| 314 | * @return string |
||
| 315 | */ |
||
| 316 | public function getCardName() |
||
| 320 | |||
| 321 | /** |
||
| 322 | * @param string $CardName |
||
| 323 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 324 | */ |
||
| 325 | public function setCardName($CardName) |
||
| 330 | |||
| 331 | /** |
||
| 332 | * @return string |
||
| 333 | */ |
||
| 334 | public function getMerchantNumber() |
||
| 338 | |||
| 339 | /** |
||
| 340 | * @param string $MerchantNumber |
||
| 341 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 342 | */ |
||
| 343 | public function setMerchantNumber($MerchantNumber) |
||
| 348 | |||
| 349 | /** |
||
| 350 | * @return string |
||
| 351 | */ |
||
| 352 | public function getHostReferenceNumber() |
||
| 356 | |||
| 357 | /** |
||
| 358 | * @param string $HostReferenceNumber |
||
| 359 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 360 | */ |
||
| 361 | public function setHostReferenceNumber($HostReferenceNumber) |
||
| 366 | |||
| 367 | /** |
||
| 368 | * @return string |
||
| 369 | */ |
||
| 370 | public function getIQWareErrorMessage() |
||
| 374 | |||
| 375 | /** |
||
| 376 | * @param string $IQWareErrorMessage |
||
| 377 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 378 | */ |
||
| 379 | public function setIQWareErrorMessage($IQWareErrorMessage) |
||
| 384 | |||
| 385 | /** |
||
| 386 | * @return int |
||
| 387 | */ |
||
| 388 | public function getAccountID() |
||
| 392 | |||
| 393 | /** |
||
| 394 | * @param int $AccountID |
||
| 395 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 396 | */ |
||
| 397 | public function setAccountID($AccountID) |
||
| 402 | |||
| 403 | /** |
||
| 404 | * @return int |
||
| 405 | */ |
||
| 406 | public function getAccountNo() |
||
| 410 | |||
| 411 | /** |
||
| 412 | * @param int $AccountNo |
||
| 413 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 414 | */ |
||
| 415 | public function setAccountNo($AccountNo) |
||
| 420 | |||
| 421 | /** |
||
| 422 | * @return string |
||
| 423 | */ |
||
| 424 | public function getAccountName() |
||
| 428 | |||
| 429 | /** |
||
| 430 | * @param string $AccountName |
||
| 431 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 432 | */ |
||
| 433 | public function setAccountName($AccountName) |
||
| 438 | |||
| 439 | /** |
||
| 440 | * @return \DateTime |
||
| 441 | */ |
||
| 442 | public function getTransactionDateTime() |
||
| 454 | |||
| 455 | /** |
||
| 456 | * @param \DateTime $TransactionDateTime |
||
| 457 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 458 | */ |
||
| 459 | public function setTransactionDateTime(\DateTime $TransactionDateTime) |
||
| 464 | |||
| 465 | /** |
||
| 466 | * @return int |
||
| 467 | */ |
||
| 468 | public function getItemCode() |
||
| 472 | |||
| 473 | /** |
||
| 474 | * @param int $ItemCode |
||
| 475 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 476 | */ |
||
| 477 | public function setItemCode($ItemCode) |
||
| 482 | |||
| 483 | /** |
||
| 484 | * @return string |
||
| 485 | */ |
||
| 486 | public function getItemText() |
||
| 490 | |||
| 491 | /** |
||
| 492 | * @param string $ItemText |
||
| 493 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 494 | */ |
||
| 495 | public function setItemText($ItemText) |
||
| 500 | |||
| 501 | /** |
||
| 502 | * @return int |
||
| 503 | */ |
||
| 504 | public function getReferenceNumber() |
||
| 508 | |||
| 509 | /** |
||
| 510 | * @param int $ReferenceNumber |
||
| 511 | * @return \Gueststream\PMS\IQWare\API\ProtobasePostResult |
||
| 512 | */ |
||
| 513 | public function setReferenceNumber($ReferenceNumber) |
||
| 518 | } |
||
| 519 |
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..