| Total Complexity | 95 |
| Total Lines | 770 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like GatewayRequest 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.
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 GatewayRequest, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 29 | class GatewayRequest extends GatewayParameterList |
||
| 30 | { |
||
| 31 | public function __construct() |
||
| 32 | { |
||
| 33 | parent::__construct(); |
||
| 34 | |||
| 35 | $this->set(self::version(), $this->getVersion()); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Transform the parameter list into an XML String. |
||
| 40 | * |
||
| 41 | * @return string |
||
| 42 | */ |
||
| 43 | public function toXMLString() |
||
| 44 | { |
||
| 45 | $xmlString = '<?xml version="1.0" encoding="UTF-8"?><gatewayRequest>'; |
||
| 46 | |||
| 47 | foreach ($this->params as $key => $value) { |
||
| 48 | $xmlString .= '<'.$key.'>'; |
||
| 49 | $xmlString .= $this->translateXML($value); |
||
| 50 | $xmlString .= '</'.$key.'>'; |
||
| 51 | } |
||
| 52 | $xmlString .= '</gatewayRequest>'; |
||
| 53 | |||
| 54 | return $xmlString; |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Translate a string to a valid XML string that can be used in an attribute or text node. |
||
| 59 | * |
||
| 60 | * @param string $sourceString |
||
| 61 | * |
||
| 62 | * @return string |
||
| 63 | */ |
||
| 64 | public function translateXML(string $sourceString) |
||
| 65 | { |
||
| 66 | $sourceString = str_replace('&', '&', $sourceString); |
||
| 67 | $sourceString = str_replace('<', '<', $sourceString); |
||
| 68 | $sourceString = str_replace('>', '>', $sourceString); |
||
| 69 | |||
| 70 | return $sourceString; |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @return string |
||
| 75 | */ |
||
| 76 | public static function version() |
||
| 77 | { |
||
| 78 | return 'version'; |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @return string |
||
| 83 | */ |
||
| 84 | public static function accountHolder() |
||
| 85 | { |
||
| 86 | return 'accountHolder'; |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @return string |
||
| 91 | */ |
||
| 92 | public static function accountNo() |
||
| 93 | { |
||
| 94 | return 'accountNo'; |
||
| 95 | } |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @return string |
||
| 99 | */ |
||
| 100 | public static function affiliate() |
||
| 101 | { |
||
| 102 | return 'affiliate'; |
||
| 103 | } |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @return string |
||
| 107 | */ |
||
| 108 | public static function amount() |
||
| 109 | { |
||
| 110 | return 'amount'; |
||
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @return string |
||
| 115 | */ |
||
| 116 | public static function avsCheck() |
||
| 117 | { |
||
| 118 | return 'avsCheck'; |
||
| 119 | } |
||
| 120 | |||
| 121 | /** |
||
| 122 | * @return string |
||
| 123 | */ |
||
| 124 | public static function billingAddress() |
||
| 125 | { |
||
| 126 | return 'billingAddress'; |
||
| 127 | } |
||
| 128 | |||
| 129 | /** |
||
| 130 | * @return string |
||
| 131 | */ |
||
| 132 | public static function billingCity() |
||
| 133 | { |
||
| 134 | return 'billingCity'; |
||
| 135 | } |
||
| 136 | |||
| 137 | /** |
||
| 138 | * @return string |
||
| 139 | */ |
||
| 140 | public static function billingCountry() |
||
| 141 | { |
||
| 142 | return 'billingCountry'; |
||
| 143 | } |
||
| 144 | |||
| 145 | /** |
||
| 146 | * @return string |
||
| 147 | */ |
||
| 148 | public static function billingState() |
||
| 149 | { |
||
| 150 | return 'billingState'; |
||
| 151 | } |
||
| 152 | |||
| 153 | /** |
||
| 154 | * @return string |
||
| 155 | */ |
||
| 156 | public static function billingType() |
||
| 157 | { |
||
| 158 | return 'billingType'; |
||
| 159 | } |
||
| 160 | |||
| 161 | /** |
||
| 162 | * @return string |
||
| 163 | */ |
||
| 164 | public static function billingZipCode() |
||
| 165 | { |
||
| 166 | return 'billingZipCode'; |
||
| 167 | } |
||
| 168 | |||
| 169 | /** |
||
| 170 | * @return string |
||
| 171 | */ |
||
| 172 | public static function browserUserAgent() |
||
| 173 | { |
||
| 174 | return 'browserUserAgent'; |
||
| 175 | } |
||
| 176 | |||
| 177 | /** |
||
| 178 | * @return string |
||
| 179 | */ |
||
| 180 | public static function browserAcceptHeader() |
||
| 181 | { |
||
| 182 | return 'browserAcceptHeader'; |
||
| 183 | } |
||
| 184 | |||
| 185 | /** |
||
| 186 | * @return string |
||
| 187 | */ |
||
| 188 | public static function captureDays() |
||
| 189 | { |
||
| 190 | return 'captureDays'; |
||
| 191 | } |
||
| 192 | |||
| 193 | /** |
||
| 194 | * @return string |
||
| 195 | */ |
||
| 196 | public static function cardNo() |
||
| 197 | { |
||
| 198 | return 'cardNo'; |
||
| 199 | } |
||
| 200 | |||
| 201 | /** |
||
| 202 | * @return string |
||
| 203 | */ |
||
| 204 | public static function cardHash() |
||
| 205 | { |
||
| 206 | return 'cardHash'; |
||
| 207 | } |
||
| 208 | |||
| 209 | /** |
||
| 210 | * @return string |
||
| 211 | */ |
||
| 212 | public static function cloneCustomerRecord() |
||
| 213 | { |
||
| 214 | return 'cloneCustomerRecord'; |
||
| 215 | } |
||
| 216 | |||
| 217 | /** |
||
| 218 | * @return string |
||
| 219 | */ |
||
| 220 | public static function cloneToCustomerId() |
||
| 221 | { |
||
| 222 | return 'cloneToCustomerID'; |
||
| 223 | } |
||
| 224 | |||
| 225 | /** |
||
| 226 | * @return string |
||
| 227 | */ |
||
| 228 | public static function currency() |
||
| 229 | { |
||
| 230 | return 'currency'; |
||
| 231 | } |
||
| 232 | |||
| 233 | /** |
||
| 234 | * @return string |
||
| 235 | */ |
||
| 236 | public static function customerFirstName() |
||
| 237 | { |
||
| 238 | return 'customerFirstName'; |
||
| 239 | } |
||
| 240 | |||
| 241 | /** |
||
| 242 | * @return string |
||
| 243 | */ |
||
| 244 | public static function customerLastName() |
||
| 245 | { |
||
| 246 | return 'customerLastName'; |
||
| 247 | } |
||
| 248 | |||
| 249 | /** |
||
| 250 | * @return string |
||
| 251 | */ |
||
| 252 | public static function customerPassword() |
||
| 253 | { |
||
| 254 | return 'customerPassword'; |
||
| 255 | } |
||
| 256 | |||
| 257 | /** |
||
| 258 | * @return string |
||
| 259 | */ |
||
| 260 | public static function customerPhoneNo() |
||
| 261 | { |
||
| 262 | return 'customerPhoneNo'; |
||
| 263 | } |
||
| 264 | |||
| 265 | /** |
||
| 266 | * @return string |
||
| 267 | */ |
||
| 268 | public static function cvv2() |
||
| 269 | { |
||
| 270 | return 'cvv2'; |
||
| 271 | } |
||
| 272 | |||
| 273 | /** |
||
| 274 | * @return string |
||
| 275 | */ |
||
| 276 | public static function cvv2Check() |
||
| 277 | { |
||
| 278 | return 'cvv2Check'; |
||
| 279 | } |
||
| 280 | |||
| 281 | /** |
||
| 282 | * @return string |
||
| 283 | */ |
||
| 284 | public static function email() |
||
| 285 | { |
||
| 286 | return 'email'; |
||
| 287 | } |
||
| 288 | |||
| 289 | /** |
||
| 290 | * @return string |
||
| 291 | */ |
||
| 292 | public static function embeddedFieldToken() |
||
| 293 | { |
||
| 294 | return 'embeddedFieldsToken'; |
||
| 295 | } |
||
| 296 | |||
| 297 | /** |
||
| 298 | * @return string |
||
| 299 | */ |
||
| 300 | public static function expireMonth() |
||
| 301 | { |
||
| 302 | return 'expireMonth'; |
||
| 303 | } |
||
| 304 | |||
| 305 | /** |
||
| 306 | * @return string |
||
| 307 | */ |
||
| 308 | public static function expireYear() |
||
| 309 | { |
||
| 310 | return 'expireYear'; |
||
| 311 | } |
||
| 312 | |||
| 313 | /** |
||
| 314 | * @return string |
||
| 315 | */ |
||
| 316 | public static function generatePostback() |
||
| 317 | { |
||
| 318 | return 'generatePostback'; |
||
| 319 | } |
||
| 320 | |||
| 321 | /** |
||
| 322 | * @return string |
||
| 323 | */ |
||
| 324 | public static function iovationBlackBox() |
||
| 325 | { |
||
| 326 | return 'iovationBlackBox'; |
||
| 327 | } |
||
| 328 | |||
| 329 | /** |
||
| 330 | * @return string |
||
| 331 | */ |
||
| 332 | public static function iovationRule() |
||
| 333 | { |
||
| 334 | return 'iovationRule'; |
||
| 335 | } |
||
| 336 | |||
| 337 | /** |
||
| 338 | * @return string |
||
| 339 | */ |
||
| 340 | public static function ipAddress() |
||
| 341 | { |
||
| 342 | return 'ipAddress'; |
||
| 343 | } |
||
| 344 | |||
| 345 | /** |
||
| 346 | * @return string |
||
| 347 | */ |
||
| 348 | public static function merchantAccount() |
||
| 349 | { |
||
| 350 | return 'merchantAccount'; |
||
| 351 | } |
||
| 352 | |||
| 353 | /** |
||
| 354 | * @return string |
||
| 355 | */ |
||
| 356 | public static function merchantCustomerId() |
||
| 357 | { |
||
| 358 | return 'merchantCustomerID'; |
||
| 359 | } |
||
| 360 | |||
| 361 | /** |
||
| 362 | * @return string |
||
| 363 | */ |
||
| 364 | public static function merchantDescriptor() |
||
| 365 | { |
||
| 366 | return 'merchantDescriptor'; |
||
| 367 | } |
||
| 368 | |||
| 369 | /** |
||
| 370 | * @return string |
||
| 371 | */ |
||
| 372 | public static function merchantDescriptorCity() |
||
| 373 | { |
||
| 374 | return 'merchantDescriptorCity'; |
||
| 375 | } |
||
| 376 | |||
| 377 | /** |
||
| 378 | * @return string |
||
| 379 | */ |
||
| 380 | public static function merchantInvoiceId() |
||
| 383 | } |
||
| 384 | |||
| 385 | /** |
||
| 386 | * @return string |
||
| 387 | */ |
||
| 388 | public static function merchantId() |
||
| 389 | { |
||
| 390 | return 'merchantID'; |
||
| 391 | } |
||
| 392 | |||
| 393 | /** |
||
| 394 | * @return string |
||
| 395 | */ |
||
| 396 | public static function merchantPassword() |
||
| 397 | { |
||
| 398 | return 'merchantPassword'; |
||
| 399 | } |
||
| 400 | |||
| 401 | /** |
||
| 402 | * @return string |
||
| 403 | */ |
||
| 404 | public static function merchantProductId() |
||
| 405 | { |
||
| 406 | return 'merchantProductID'; |
||
| 407 | } |
||
| 408 | |||
| 409 | /** |
||
| 410 | * @return string |
||
| 411 | */ |
||
| 412 | public static function merchantSiteId() |
||
| 413 | { |
||
| 414 | return 'merchantSiteID'; |
||
| 415 | } |
||
| 416 | |||
| 417 | /** |
||
| 418 | * @return string |
||
| 419 | */ |
||
| 420 | public static function omitReceipt() |
||
| 421 | { |
||
| 422 | return 'omitReceipt'; |
||
| 423 | } |
||
| 424 | |||
| 425 | /** |
||
| 426 | * @return string |
||
| 427 | */ |
||
| 428 | public static function pares() |
||
| 429 | { |
||
| 430 | return 'PARES'; |
||
| 431 | } |
||
| 432 | |||
| 433 | /** |
||
| 434 | * @return string |
||
| 435 | */ |
||
| 436 | public static function partialAuthFlag() |
||
| 437 | { |
||
| 438 | return 'partialAuthFlag'; |
||
| 439 | } |
||
| 440 | |||
| 441 | /** |
||
| 442 | * @return string |
||
| 443 | */ |
||
| 444 | public static function payInfoTransactId() |
||
| 445 | { |
||
| 446 | return 'payInfoTransactID'; |
||
| 447 | } |
||
| 448 | |||
| 449 | /** |
||
| 450 | * @return string |
||
| 451 | */ |
||
| 452 | public static function rebillFrequency() |
||
| 453 | { |
||
| 454 | return 'rebillFrequency'; |
||
| 455 | } |
||
| 456 | |||
| 457 | /** |
||
| 458 | * @return string |
||
| 459 | */ |
||
| 460 | public static function rebillAmount() |
||
| 461 | { |
||
| 462 | return 'rebillAmount'; |
||
| 463 | } |
||
| 464 | |||
| 465 | /** |
||
| 466 | * @return string |
||
| 467 | */ |
||
| 468 | public static function rebillStart() |
||
| 469 | { |
||
| 470 | return 'rebillStart'; |
||
| 471 | } |
||
| 472 | |||
| 473 | /** |
||
| 474 | * @return string |
||
| 475 | */ |
||
| 476 | public static function rebillEndDate() |
||
| 479 | } |
||
| 480 | |||
| 481 | /** |
||
| 482 | * @return string |
||
| 483 | */ |
||
| 484 | public static function rebillCount() |
||
| 485 | { |
||
| 486 | return 'rebillCount'; |
||
| 487 | } |
||
| 488 | |||
| 489 | /** |
||
| 490 | * @return string |
||
| 491 | */ |
||
| 492 | public static function rebillSuspend() |
||
| 493 | { |
||
| 494 | return 'rebillSuspend'; |
||
| 495 | } |
||
| 496 | |||
| 497 | /** |
||
| 498 | * @return string |
||
| 499 | */ |
||
| 500 | public static function rebillResume() |
||
| 501 | { |
||
| 502 | return 'rebillResume'; |
||
| 503 | } |
||
| 504 | |||
| 505 | /** |
||
| 506 | * @return string |
||
| 507 | */ |
||
| 508 | public static function referenceGuid() |
||
| 509 | { |
||
| 510 | return 'referenceGUID'; |
||
| 511 | } |
||
| 512 | |||
| 513 | /** |
||
| 514 | * @return string |
||
| 515 | */ |
||
| 516 | public static function referralNo() |
||
| 517 | { |
||
| 518 | return 'referralNo'; |
||
| 519 | } |
||
| 520 | |||
| 521 | /** |
||
| 522 | * @return string |
||
| 523 | */ |
||
| 524 | public static function referringMerchantId() |
||
| 525 | { |
||
| 526 | return 'referringMerchantID'; |
||
| 527 | } |
||
| 528 | |||
| 529 | /** |
||
| 530 | * @return string |
||
| 531 | */ |
||
| 532 | public static function referredCustomerId() |
||
| 533 | { |
||
| 534 | return 'referredCustomerID'; |
||
| 535 | } |
||
| 536 | |||
| 537 | /** |
||
| 538 | * @return string |
||
| 539 | */ |
||
| 540 | public static function routingNo() |
||
| 541 | { |
||
| 542 | return 'routingNo'; |
||
| 543 | } |
||
| 544 | |||
| 545 | /** |
||
| 546 | * @return string |
||
| 547 | */ |
||
| 548 | public static function savingsAccount() |
||
| 549 | { |
||
| 550 | return 'savingsAccount'; |
||
| 551 | } |
||
| 552 | |||
| 553 | /** |
||
| 554 | * @return string |
||
| 555 | */ |
||
| 556 | public static function scrub() |
||
| 557 | { |
||
| 558 | return 'scrub'; |
||
| 559 | } |
||
| 560 | |||
| 561 | /** |
||
| 562 | * @return string |
||
| 563 | */ |
||
| 564 | public static function scrubActivity() |
||
| 565 | { |
||
| 566 | return 'scrubActivity'; |
||
| 567 | } |
||
| 568 | |||
| 569 | /** |
||
| 570 | * @return string |
||
| 571 | */ |
||
| 572 | public static function scrubNegDB() |
||
| 573 | { |
||
| 574 | return 'scrubNegDB'; |
||
| 575 | } |
||
| 576 | |||
| 577 | /** |
||
| 578 | * @return string |
||
| 579 | */ |
||
| 580 | public static function scrubProfile() |
||
| 583 | } |
||
| 584 | |||
| 585 | /** |
||
| 586 | * @return string |
||
| 587 | */ |
||
| 588 | public static function ssNumber() |
||
| 589 | { |
||
| 590 | return 'ssNumber'; |
||
| 591 | } |
||
| 592 | |||
| 593 | /** |
||
| 594 | * @return string |
||
| 595 | */ |
||
| 596 | public static function subMerchantId() |
||
| 597 | { |
||
| 598 | return 'subMerchantID'; |
||
| 599 | } |
||
| 600 | |||
| 601 | /** |
||
| 602 | * @return string |
||
| 603 | */ |
||
| 604 | public static function threatMetrixSessionId() |
||
| 605 | { |
||
| 606 | return 'threatMetrixSessionID'; |
||
| 607 | } |
||
| 608 | |||
| 609 | /** |
||
| 610 | * @return string |
||
| 611 | */ |
||
| 612 | public static function transactId() |
||
| 613 | { |
||
| 614 | return self::referenceGuid(); |
||
| 615 | } |
||
| 616 | |||
| 617 | /** |
||
| 618 | * @return string |
||
| 619 | */ |
||
| 620 | public static function transactionType() |
||
| 621 | { |
||
| 622 | return 'transactionType'; |
||
| 623 | } |
||
| 624 | |||
| 625 | /** |
||
| 626 | * @return string |
||
| 627 | */ |
||
| 628 | public static function udf01() |
||
| 629 | { |
||
| 630 | return 'udf01'; |
||
| 631 | } |
||
| 632 | |||
| 633 | /** |
||
| 634 | * @return string |
||
| 635 | */ |
||
| 636 | public static function udf02() |
||
| 637 | { |
||
| 638 | return 'udf02'; |
||
| 639 | } |
||
| 640 | |||
| 641 | /** |
||
| 642 | * @return string |
||
| 643 | */ |
||
| 644 | public static function use3DSecure() |
||
| 645 | { |
||
| 646 | return 'use3DSecure'; |
||
| 647 | } |
||
| 648 | |||
| 649 | /** |
||
| 650 | * @return string |
||
| 651 | */ |
||
| 652 | public static function username() |
||
| 653 | { |
||
| 654 | return 'username'; |
||
| 655 | } |
||
| 656 | |||
| 657 | /** |
||
| 658 | * @return string |
||
| 659 | */ |
||
| 660 | public static function xsellMerchantID() |
||
| 661 | { |
||
| 662 | return 'xsellMerchantID'; |
||
| 663 | } |
||
| 664 | |||
| 665 | /** |
||
| 666 | * @return string |
||
| 667 | */ |
||
| 668 | public static function xsellCustomerID() |
||
| 671 | } |
||
| 672 | |||
| 673 | /** |
||
| 674 | * @return string |
||
| 675 | */ |
||
| 676 | public static function xsellReferenceXact() |
||
| 677 | { |
||
| 678 | return 'xsellReferenceXact'; |
||
| 679 | } |
||
| 680 | |||
| 681 | /** |
||
| 682 | * @return string |
||
| 683 | */ |
||
| 684 | public static function threeDCheck() |
||
| 685 | { |
||
| 686 | return 'ThreeDCheck'; |
||
| 687 | } |
||
| 688 | |||
| 689 | /** |
||
| 690 | * @return string |
||
| 691 | */ |
||
| 692 | public static function threeDECI() |
||
| 693 | { |
||
| 694 | return 'ThreeDECI'; |
||
| 695 | } |
||
| 696 | |||
| 697 | /** |
||
| 698 | * @return string |
||
| 699 | */ |
||
| 700 | public static function threeDCavvUcaf() |
||
| 701 | { |
||
| 702 | return 'ThreeDCavvUcaf'; |
||
| 703 | } |
||
| 704 | |||
| 705 | /** |
||
| 706 | * @return string |
||
| 707 | */ |
||
| 708 | public static function threeDXID() |
||
| 709 | { |
||
| 710 | return 'ThreeDXID'; |
||
| 711 | } |
||
| 712 | |||
| 713 | /** |
||
| 714 | * @return string |
||
| 715 | */ |
||
| 716 | public static function failedServer() |
||
| 717 | { |
||
| 718 | return 'failedServer'; |
||
| 719 | } |
||
| 720 | |||
| 721 | /** |
||
| 722 | * @return string |
||
| 723 | */ |
||
| 724 | public static function failedGuid() |
||
| 725 | { |
||
| 726 | return 'failedGUID'; |
||
| 727 | } |
||
| 728 | |||
| 729 | /** |
||
| 730 | * @return string |
||
| 731 | */ |
||
| 732 | public static function failedResponseCode() |
||
| 733 | { |
||
| 734 | return 'failedResponseCode'; |
||
| 735 | } |
||
| 736 | |||
| 737 | /** |
||
| 738 | * @return string |
||
| 739 | */ |
||
| 740 | public static function failedReasonCode() |
||
| 741 | { |
||
| 742 | return 'failedReasonCode'; |
||
| 743 | } |
||
| 744 | |||
| 745 | /** |
||
| 746 | * @return string |
||
| 747 | */ |
||
| 748 | public static function gatewayServer() |
||
| 749 | { |
||
| 750 | return 'gatewayServer'; |
||
| 751 | } |
||
| 752 | |||
| 753 | /** |
||
| 754 | * @return string |
||
| 755 | */ |
||
| 756 | public static function gatewayProtocol() |
||
| 757 | { |
||
| 758 | return 'gatewayProtocol'; |
||
| 759 | } |
||
| 760 | |||
| 761 | /** |
||
| 762 | * @return string |
||
| 763 | */ |
||
| 764 | public static function gatewayPortNo() |
||
| 765 | { |
||
| 766 | return 'gatewayPortNo'; |
||
| 767 | } |
||
| 768 | |||
| 769 | /** |
||
| 770 | * @return string |
||
| 771 | */ |
||
| 772 | public static function gatewayServlet() |
||
| 773 | { |
||
| 774 | return 'gatewayServlet'; |
||
| 775 | } |
||
| 776 | |||
| 777 | /** |
||
| 778 | * @return string |
||
| 779 | */ |
||
| 780 | public static function gatewayUrl() |
||
| 783 | } |
||
| 784 | |||
| 785 | /** |
||
| 786 | * @return string |
||
| 787 | */ |
||
| 788 | public static function gatewayConnectTimeout() |
||
| 789 | { |
||
| 790 | return 'gatewayConnectTimeout'; |
||
| 791 | } |
||
| 792 | |||
| 793 | /** |
||
| 794 | * @return string |
||
| 795 | */ |
||
| 796 | public static function gatewayReadTimeout() |
||
| 797 | { |
||
| 798 | return 'gatewayReadTimeout'; |
||
| 799 | } |
||
| 800 | } |
||
| 801 |