Complex classes like Callback 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 Callback, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 10 | abstract class Callback implements CallbackInterface |
||
| 11 | { |
||
| 12 | use ORMBehaviors\Timestampable\Timestampable; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var mixed |
||
| 16 | */ |
||
| 17 | protected $id; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * The order id will always be an integer in Dandomain so we use type int |
||
| 21 | * instead of string (although Altapay handles order id as string) |
||
| 22 | * |
||
| 23 | * @var int |
||
| 24 | * |
||
| 25 | * @ORM\Column(type="integer") |
||
| 26 | */ |
||
| 27 | protected $orderId; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var float |
||
| 31 | * |
||
| 32 | * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true) |
||
| 33 | */ |
||
| 34 | protected $amount; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var int |
||
| 38 | * |
||
| 39 | * @ORM\Column(type="integer", nullable=true) |
||
| 40 | */ |
||
| 41 | protected $currency; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var string |
||
| 45 | * |
||
| 46 | * @ORM\Column(type="string", nullable=true) |
||
| 47 | */ |
||
| 48 | protected $language; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @var array |
||
| 52 | * |
||
| 53 | * @ORM\Column(type="array", nullable=true) |
||
| 54 | */ |
||
| 55 | protected $transactionInfo; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @var string |
||
| 59 | * |
||
| 60 | * @ORM\Column(type="string", nullable=true) |
||
| 61 | */ |
||
| 62 | protected $status; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var string |
||
| 66 | * |
||
| 67 | * @ORM\Column(type="string", nullable=true) |
||
| 68 | */ |
||
| 69 | protected $errorMessage; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @var string |
||
| 73 | * |
||
| 74 | * @ORM\Column(type="string", nullable=true) |
||
| 75 | */ |
||
| 76 | protected $merchantErrorMessage; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @var boolean |
||
| 80 | * |
||
| 81 | * @ORM\Column(type="boolean", nullable=true) |
||
| 82 | */ |
||
| 83 | protected $cardholderMessageMustBeShown; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @var string |
||
| 87 | * |
||
| 88 | * @ORM\Column(type="string", nullable=true) |
||
| 89 | */ |
||
| 90 | protected $transactionId; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @var string |
||
| 94 | * |
||
| 95 | * @ORM\Column(type="string", nullable=true) |
||
| 96 | */ |
||
| 97 | protected $type; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @var string |
||
| 101 | * |
||
| 102 | * @ORM\Column(type="string", nullable=true) |
||
| 103 | */ |
||
| 104 | protected $paymentStatus; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @var string |
||
| 108 | * |
||
| 109 | * @ORM\Column(type="string", nullable=true) |
||
| 110 | */ |
||
| 111 | protected $maskedCreditCard; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @var string |
||
| 115 | * |
||
| 116 | * @ORM\Column(type="string", nullable=true) |
||
| 117 | */ |
||
| 118 | protected $blacklistToken; |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @var string |
||
| 122 | * |
||
| 123 | * @ORM\Column(type="string", nullable=true) |
||
| 124 | */ |
||
| 125 | protected $creditCardToken; |
||
| 126 | |||
| 127 | /** |
||
| 128 | * @var string |
||
| 129 | * |
||
| 130 | * @ORM\Column(type="string", nullable=true) |
||
| 131 | */ |
||
| 132 | protected $nature; |
||
| 133 | |||
| 134 | /** |
||
| 135 | * @var boolean |
||
| 136 | * |
||
| 137 | * @ORM\Column(type="boolean", nullable=true) |
||
| 138 | */ |
||
| 139 | protected $requireCapture; |
||
| 140 | |||
| 141 | /** |
||
| 142 | * @var string |
||
| 143 | * |
||
| 144 | * @ORM\Column(type="string", nullable=true) |
||
| 145 | */ |
||
| 146 | protected $xml; |
||
| 147 | |||
| 148 | /** |
||
| 149 | * @var string |
||
| 150 | * |
||
| 151 | * @ORM\Column(type="string", nullable=true) |
||
| 152 | */ |
||
| 153 | protected $checksum; |
||
| 154 | |||
| 155 | /** |
||
| 156 | * @var float |
||
| 157 | * |
||
| 158 | * @ORM\Column(type="float", nullable=true) |
||
| 159 | */ |
||
| 160 | protected $fraudRiskScore; |
||
| 161 | |||
| 162 | /** |
||
| 163 | * @var string |
||
| 164 | * |
||
| 165 | * @ORM\Column(type="string", nullable=true) |
||
| 166 | */ |
||
| 167 | protected $fraudExplanation; |
||
| 168 | |||
| 169 | /** |
||
| 170 | * @var string |
||
| 171 | * |
||
| 172 | * @ORM\Column(type="string", nullable=true) |
||
| 173 | */ |
||
| 174 | protected $fraudRecommendation; |
||
| 175 | |||
| 176 | /** |
||
| 177 | * @var string |
||
| 178 | * |
||
| 179 | * @ORM\Column(type="string", nullable=true) |
||
| 180 | */ |
||
| 181 | protected $avsCode; |
||
| 182 | |||
| 183 | /** |
||
| 184 | * @var string |
||
| 185 | * |
||
| 186 | * @ORM\Column(type="string", nullable=true) |
||
| 187 | */ |
||
| 188 | protected $avsText; |
||
| 189 | |||
| 190 | /** |
||
| 191 | * This contains the request string |
||
| 192 | * |
||
| 193 | * @var string |
||
| 194 | * |
||
| 195 | * @ORM\Column(type="text", nullable=true) |
||
| 196 | */ |
||
| 197 | protected $request; |
||
| 198 | |||
| 199 | /** |
||
| 200 | * @var PaymentInterface |
||
| 201 | */ |
||
| 202 | protected $payment; |
||
| 203 | |||
| 204 | /** |
||
| 205 | * @inheritdoc |
||
| 206 | */ |
||
| 207 | public function getId() |
||
| 211 | |||
| 212 | /** |
||
| 213 | * @inheritdoc |
||
| 214 | */ |
||
| 215 | public function getOrderId(): ?int |
||
| 219 | |||
| 220 | /** |
||
| 221 | * @inheritdoc |
||
| 222 | */ |
||
| 223 | public function setOrderId(int $orderId) : CallbackInterface |
||
| 228 | |||
| 229 | /** |
||
| 230 | * @inheritdoc |
||
| 231 | */ |
||
| 232 | public function getAmount(): ?float |
||
| 236 | |||
| 237 | /** |
||
| 238 | * @inheritdoc |
||
| 239 | */ |
||
| 240 | public function setAmount(float $amount) : CallbackInterface |
||
| 245 | |||
| 246 | /** |
||
| 247 | * @inheritdoc |
||
| 248 | */ |
||
| 249 | public function getCurrency(): ?int |
||
| 253 | |||
| 254 | /** |
||
| 255 | * @inheritdoc |
||
| 256 | */ |
||
| 257 | public function setCurrency(int $currency) : CallbackInterface |
||
| 262 | |||
| 263 | /** |
||
| 264 | * @inheritdoc |
||
| 265 | */ |
||
| 266 | public function getLanguage(): ?string |
||
| 270 | |||
| 271 | /** |
||
| 272 | * @inheritdoc |
||
| 273 | */ |
||
| 274 | public function setLanguage(string $language) : CallbackInterface |
||
| 279 | |||
| 280 | /** |
||
| 281 | * @inheritdoc |
||
| 282 | */ |
||
| 283 | public function getTransactionInfo(): ?array |
||
| 287 | |||
| 288 | /** |
||
| 289 | * @inheritdoc |
||
| 290 | */ |
||
| 291 | public function setTransactionInfo(array $transactionInfo) : CallbackInterface |
||
| 296 | |||
| 297 | /** |
||
| 298 | * @inheritdoc |
||
| 299 | */ |
||
| 300 | public function getStatus(): ?string |
||
| 304 | |||
| 305 | /** |
||
| 306 | * @inheritdoc |
||
| 307 | */ |
||
| 308 | public function setStatus(string $status) : CallbackInterface |
||
| 313 | |||
| 314 | /** |
||
| 315 | * @inheritdoc |
||
| 316 | */ |
||
| 317 | public function getErrorMessage(): ?string |
||
| 321 | |||
| 322 | /** |
||
| 323 | * @inheritdoc |
||
| 324 | */ |
||
| 325 | public function setErrorMessage(string $errorMessage) : CallbackInterface |
||
| 330 | |||
| 331 | /** |
||
| 332 | * @inheritdoc |
||
| 333 | */ |
||
| 334 | public function getMerchantErrorMessage(): ?string |
||
| 338 | |||
| 339 | /** |
||
| 340 | * @inheritdoc |
||
| 341 | */ |
||
| 342 | public function setMerchantErrorMessage(string $merchantErrorMessage) : CallbackInterface |
||
| 347 | |||
| 348 | /** |
||
| 349 | * @inheritdoc |
||
| 350 | */ |
||
| 351 | public function isCardholderMessageMustBeShown(): ?bool |
||
| 355 | |||
| 356 | /** |
||
| 357 | * @inheritdoc |
||
| 358 | */ |
||
| 359 | public function setCardholderMessageMustBeShown(bool $cardholderMessageMustBeShown) : CallbackInterface |
||
| 364 | |||
| 365 | /** |
||
| 366 | * @inheritdoc |
||
| 367 | */ |
||
| 368 | public function getTransactionId(): ?string |
||
| 372 | |||
| 373 | /** |
||
| 374 | * @inheritdoc |
||
| 375 | */ |
||
| 376 | public function setTransactionId(string $transactionId) : CallbackInterface |
||
| 381 | |||
| 382 | /** |
||
| 383 | * @inheritdoc |
||
| 384 | */ |
||
| 385 | public function getType(): ?string |
||
| 389 | |||
| 390 | /** |
||
| 391 | * @inheritdoc |
||
| 392 | */ |
||
| 393 | public function setType(string $type) : CallbackInterface |
||
| 398 | |||
| 399 | /** |
||
| 400 | * @inheritdoc |
||
| 401 | */ |
||
| 402 | public function getPaymentStatus(): ?string |
||
| 406 | |||
| 407 | /** |
||
| 408 | * @inheritdoc |
||
| 409 | */ |
||
| 410 | public function setPaymentStatus(string $paymentStatus) : CallbackInterface |
||
| 415 | |||
| 416 | /** |
||
| 417 | * @inheritdoc |
||
| 418 | */ |
||
| 419 | public function getMaskedCreditCard(): ?string |
||
| 423 | |||
| 424 | /** |
||
| 425 | * @inheritdoc |
||
| 426 | */ |
||
| 427 | public function setMaskedCreditCard(string $maskedCreditCard) : CallbackInterface |
||
| 432 | |||
| 433 | /** |
||
| 434 | * @inheritdoc |
||
| 435 | */ |
||
| 436 | public function getBlacklistToken(): ?string |
||
| 440 | |||
| 441 | /** |
||
| 442 | * @inheritdoc |
||
| 443 | */ |
||
| 444 | public function setBlacklistToken(string $blacklistToken) : CallbackInterface |
||
| 449 | |||
| 450 | /** |
||
| 451 | * @inheritdoc |
||
| 452 | */ |
||
| 453 | public function getCreditCardToken(): ?string |
||
| 457 | |||
| 458 | /** |
||
| 459 | * @inheritdoc |
||
| 460 | */ |
||
| 461 | public function setCreditCardToken(string $creditCardToken) : CallbackInterface |
||
| 466 | |||
| 467 | /** |
||
| 468 | * @inheritdoc |
||
| 469 | */ |
||
| 470 | public function getNature(): ?string |
||
| 474 | |||
| 475 | /** |
||
| 476 | * @inheritdoc |
||
| 477 | */ |
||
| 478 | public function setNature(string $nature) : CallbackInterface |
||
| 483 | |||
| 484 | /** |
||
| 485 | * @inheritdoc |
||
| 486 | */ |
||
| 487 | public function isRequireCapture(): ?bool |
||
| 491 | |||
| 492 | /** |
||
| 493 | * @inheritdoc |
||
| 494 | */ |
||
| 495 | public function setRequireCapture(bool $requireCapture) : CallbackInterface |
||
| 500 | |||
| 501 | /** |
||
| 502 | * @inheritdoc |
||
| 503 | */ |
||
| 504 | public function getXml(): ?string |
||
| 508 | |||
| 509 | /** |
||
| 510 | * @inheritdoc |
||
| 511 | */ |
||
| 512 | public function setXml(string $xml) : CallbackInterface |
||
| 517 | |||
| 518 | /** |
||
| 519 | * @inheritdoc |
||
| 520 | */ |
||
| 521 | public function getChecksum(): ?string |
||
| 525 | |||
| 526 | /** |
||
| 527 | * @inheritdoc |
||
| 528 | */ |
||
| 529 | public function setChecksum(string $checksum) : CallbackInterface |
||
| 534 | |||
| 535 | /** |
||
| 536 | * @inheritdoc |
||
| 537 | */ |
||
| 538 | public function getFraudRiskScore(): ?float |
||
| 542 | |||
| 543 | /** |
||
| 544 | * @inheritdoc |
||
| 545 | */ |
||
| 546 | public function setFraudRiskScore(float $fraudRiskScore) : CallbackInterface |
||
| 551 | |||
| 552 | /** |
||
| 553 | * @inheritdoc |
||
| 554 | */ |
||
| 555 | public function getFraudExplanation(): ?string |
||
| 559 | |||
| 560 | /** |
||
| 561 | * @inheritdoc |
||
| 562 | */ |
||
| 563 | public function setFraudExplanation(string $fraudExplanation) : CallbackInterface |
||
| 568 | |||
| 569 | /** |
||
| 570 | * @inheritdoc |
||
| 571 | */ |
||
| 572 | public function getFraudRecommendation(): ?string |
||
| 576 | |||
| 577 | /** |
||
| 578 | * @inheritdoc |
||
| 579 | */ |
||
| 580 | public function setFraudRecommendation(string $fraudRecommendation) : CallbackInterface |
||
| 585 | |||
| 586 | /** |
||
| 587 | * @inheritdoc |
||
| 588 | */ |
||
| 589 | public function getAvsCode(): ?string |
||
| 593 | |||
| 594 | /** |
||
| 595 | * @inheritdoc |
||
| 596 | */ |
||
| 597 | public function setAvsCode(string $avsCode) : CallbackInterface |
||
| 602 | |||
| 603 | /** |
||
| 604 | * @inheritdoc |
||
| 605 | */ |
||
| 606 | public function getAvsText(): ?string |
||
| 610 | |||
| 611 | /** |
||
| 612 | * @inheritdoc |
||
| 613 | */ |
||
| 614 | public function setAvsText(string $avsText) : CallbackInterface |
||
| 619 | |||
| 620 | /** |
||
| 621 | * @inheritdoc |
||
| 622 | */ |
||
| 623 | public function getRequest() : ?string |
||
| 627 | |||
| 628 | /** |
||
| 629 | * @inheritdoc |
||
| 630 | */ |
||
| 631 | public function setRequest(string $request) : CallbackInterface |
||
| 636 | |||
| 637 | /** |
||
| 638 | * @inheritdoc |
||
| 639 | */ |
||
| 640 | public function getPayment(): ?PaymentInterface |
||
| 644 | |||
| 645 | /** |
||
| 646 | * @inheritdoc |
||
| 647 | */ |
||
| 648 | public function setPayment(PaymentInterface $payment) : CallbackInterface |
||
| 653 | } |