| Total Complexity | 43 |
| Total Lines | 545 |
| Duplicated Lines | 0 % |
| Changes | 18 | ||
| Bugs | 1 | Features | 4 |
Complex classes like ComputopConfig 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 ComputopConfig, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 15 | class ComputopConfig extends AbstractBundleConfig |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | public const OMS_STATUS_NEW = 'new'; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | public const OMS_STATUS_INITIALIZED = 'init'; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var string |
||
| 29 | */ |
||
| 30 | public const OMS_STATUS_AUTHORIZED = 'authorized'; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var string |
||
| 34 | */ |
||
| 35 | public const OMS_STATUS_CONFIRMED = 'confirmed'; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var string |
||
| 39 | */ |
||
| 40 | public const OMS_STATUS_AUTHORIZATION_FAILED = 'authorization failed'; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var string |
||
| 44 | */ |
||
| 45 | public const OMS_STATUS_CAPTURED = 'captured'; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var string |
||
| 49 | */ |
||
| 50 | public const OMS_STATUS_CAPTURING_FAILED = 'capture failed'; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var string |
||
| 54 | */ |
||
| 55 | public const OMS_STATUS_CANCELLED = 'cancelled'; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @var string |
||
| 59 | */ |
||
| 60 | public const OMS_STATUS_REFUNDED = 'refunded'; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @var string |
||
| 64 | */ |
||
| 65 | public const AUTHORIZE_METHOD = 'AUTHORIZE'; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @var string |
||
| 69 | */ |
||
| 70 | public const CAPTURE_METHOD = 'CAPTURE'; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @var string |
||
| 74 | */ |
||
| 75 | public const REVERSE_METHOD = 'REVERSE'; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @var string |
||
| 79 | */ |
||
| 80 | public const INQUIRE_METHOD = 'INQUIRE'; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @var string |
||
| 84 | */ |
||
| 85 | public const REFUND_METHOD = 'REFUND'; |
||
| 86 | |||
| 87 | //Events |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @var string |
||
| 91 | */ |
||
| 92 | public const COMPUTOP_OMS_EVENT_CAPTURE = 'capture'; |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @var string |
||
| 96 | */ |
||
| 97 | public const COMPUTOP_OMS_EVENT_AUTHORIZE = 'authorize'; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Refund with shipment price |
||
| 101 | * |
||
| 102 | * @var bool |
||
| 103 | */ |
||
| 104 | public const COMPUTOP_REFUND_SHIPMENT_PRICE_ENABLED = true; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @var string |
||
| 108 | */ |
||
| 109 | protected const OMS_STATUS_AUTHORIZE_REQUEST = 'authorize request'; |
||
| 110 | |||
| 111 | /** |
||
| 112 | * @api |
||
| 113 | * |
||
| 114 | * @return string |
||
| 115 | */ |
||
| 116 | public function getMerchantId() |
||
| 117 | { |
||
| 118 | return $this->get(ComputopApiConstants::MERCHANT_ID); |
||
| 119 | } |
||
| 120 | |||
| 121 | /** |
||
| 122 | * @api |
||
| 123 | * |
||
| 124 | * @return string |
||
| 125 | */ |
||
| 126 | public function getBlowfishPass() |
||
| 127 | { |
||
| 128 | return $this->get(ComputopApiConstants::BLOWFISH_PASSWORD); |
||
| 129 | } |
||
| 130 | |||
| 131 | /** |
||
| 132 | * @api |
||
| 133 | * |
||
| 134 | * @return string |
||
| 135 | */ |
||
| 136 | public function getAuthorizeAction() |
||
| 137 | { |
||
| 138 | return $this->get(ComputopConstants::AUTHORIZE_ACTION); |
||
| 139 | } |
||
| 140 | |||
| 141 | /** |
||
| 142 | * @api |
||
| 143 | * |
||
| 144 | * @return string |
||
| 145 | */ |
||
| 146 | public function getCaptureAction() |
||
| 147 | { |
||
| 148 | return $this->get(ComputopConstants::CAPTURE_ACTION); |
||
| 149 | } |
||
| 150 | |||
| 151 | /** |
||
| 152 | * @api |
||
| 153 | * |
||
| 154 | * @return string |
||
| 155 | */ |
||
| 156 | public function getRefundAction() |
||
| 157 | { |
||
| 158 | return $this->get(ComputopConstants::REFUND_ACTION); |
||
| 159 | } |
||
| 160 | |||
| 161 | /** |
||
| 162 | * @api |
||
| 163 | * |
||
| 164 | * @return string |
||
| 165 | */ |
||
| 166 | public function getInquireAction() |
||
| 167 | { |
||
| 168 | return $this->get(ComputopConstants::INQUIRE_ACTION); |
||
| 169 | } |
||
| 170 | |||
| 171 | /** |
||
| 172 | * @api |
||
| 173 | * |
||
| 174 | * @return string |
||
| 175 | */ |
||
| 176 | public function getReverseAction() |
||
| 177 | { |
||
| 178 | return $this->get(ComputopConstants::REVERSE_ACTION); |
||
| 179 | } |
||
| 180 | |||
| 181 | /** |
||
| 182 | * @api |
||
| 183 | * |
||
| 184 | * @return string |
||
| 185 | */ |
||
| 186 | public function getIdealInitAction() |
||
| 187 | { |
||
| 188 | return $this->get(ComputopConstants::IDEAL_INIT_ACTION); |
||
| 189 | } |
||
| 190 | |||
| 191 | /** |
||
| 192 | * @api |
||
| 193 | * |
||
| 194 | * @return string |
||
| 195 | */ |
||
| 196 | public function getPaydirektInitAction() |
||
| 197 | { |
||
| 198 | return $this->get(ComputopConstants::PAYDIREKT_INIT_ACTION); |
||
| 199 | } |
||
| 200 | |||
| 201 | /** |
||
| 202 | * @api |
||
| 203 | * |
||
| 204 | * @return string |
||
| 205 | */ |
||
| 206 | public function getPayuCeeSingleInitAction(): string |
||
| 207 | { |
||
| 208 | return $this->get(ComputopConstants::PAYU_CEE_SINGLE_INIT_ACTION); |
||
| 209 | } |
||
| 210 | |||
| 211 | /** |
||
| 212 | * @api |
||
| 213 | * |
||
| 214 | * @return string |
||
| 215 | */ |
||
| 216 | public function getSofortInitAction() |
||
| 217 | { |
||
| 218 | return $this->get(ComputopConstants::SOFORT_INIT_ACTION); |
||
| 219 | } |
||
| 220 | |||
| 221 | /** |
||
| 222 | * @api |
||
| 223 | * |
||
| 224 | * @return string |
||
| 225 | */ |
||
| 226 | public function getEasyCreditStatusUrl() |
||
| 227 | { |
||
| 228 | return $this->get(ComputopConstants::EASY_CREDIT_STATUS_ACTION); |
||
| 229 | } |
||
| 230 | |||
| 231 | /** |
||
| 232 | * @api |
||
| 233 | * |
||
| 234 | * @return string |
||
| 235 | */ |
||
| 236 | public function getEasyCreditAuthorizeUrl() |
||
| 237 | { |
||
| 238 | return $this->get(ComputopConstants::EASY_CREDIT_AUTHORIZE_ACTION); |
||
| 239 | } |
||
| 240 | |||
| 241 | /** |
||
| 242 | * @api |
||
| 243 | * |
||
| 244 | * @return string |
||
| 245 | */ |
||
| 246 | public function getPayNowInitActionUrl() |
||
| 247 | { |
||
| 248 | return $this->get(ComputopConstants::PAY_NOW_INIT_ACTION); |
||
| 249 | } |
||
| 250 | |||
| 251 | /** |
||
| 252 | * @api |
||
| 253 | * |
||
| 254 | * @return bool |
||
| 255 | */ |
||
| 256 | public function isRefundShipmentPriceEnabled() |
||
| 257 | { |
||
| 258 | return static::COMPUTOP_REFUND_SHIPMENT_PRICE_ENABLED; |
||
| 259 | } |
||
| 260 | |||
| 261 | /** |
||
| 262 | * @api |
||
| 263 | * |
||
| 264 | * @return array |
||
| 265 | */ |
||
| 266 | public function getBeforeInitStatuses(): array |
||
| 267 | { |
||
| 268 | return [ |
||
| 269 | $this->getOmsStatusNew(), |
||
| 270 | ]; |
||
| 271 | } |
||
| 272 | |||
| 273 | /** |
||
| 274 | * @api |
||
| 275 | * |
||
| 276 | * @return array |
||
| 277 | */ |
||
| 278 | public function getBeforeAuthorizeStatuses(): array |
||
| 279 | { |
||
| 280 | return [ |
||
| 281 | $this->getOmsStatusNew(), |
||
| 282 | $this->getOmsStatusInitialized(), |
||
| 283 | $this->getAuthorizeRequestOmsStatus(), |
||
| 284 | $this->getOmsStatusAuthorizationFailed(), |
||
| 285 | ]; |
||
| 286 | } |
||
| 287 | |||
| 288 | /** |
||
| 289 | * @api |
||
| 290 | * |
||
| 291 | * @return array |
||
| 292 | */ |
||
| 293 | public function getBeforeCaptureStatuses(): array |
||
| 294 | { |
||
| 295 | $statusesBeforeAuthorize = $this->getBeforeAuthorizeStatuses(); |
||
| 296 | $statusesBeforeAuthorize[] = $this->getOmsStatusAuthorized(); |
||
| 297 | $statusesBeforeAuthorize[] = $this->getOmsStatusConfirmed(); |
||
| 298 | $statusesBeforeAuthorize[] = $this->getOmsStatusCancelled(); |
||
| 299 | |||
| 300 | return $statusesBeforeAuthorize; |
||
| 301 | } |
||
| 302 | |||
| 303 | /** |
||
| 304 | * @api |
||
| 305 | * |
||
| 306 | * @return array |
||
| 307 | */ |
||
| 308 | public function getBeforeRefundStatuses(): array |
||
| 309 | { |
||
| 310 | $statusesBeforeCaptured = $this->getBeforeCaptureStatuses(); |
||
| 311 | $statusesBeforeCaptured[] = $this->getOmsStatusCaptured(); |
||
| 312 | |||
| 313 | return $statusesBeforeCaptured; |
||
| 314 | } |
||
| 315 | |||
| 316 | /** |
||
| 317 | * @api |
||
| 318 | * |
||
| 319 | * @return string |
||
| 320 | */ |
||
| 321 | public function getOmsStatusNew() |
||
| 322 | { |
||
| 323 | return static::OMS_STATUS_NEW; |
||
| 324 | } |
||
| 325 | |||
| 326 | /** |
||
| 327 | * @api |
||
| 328 | * |
||
| 329 | * @return string |
||
| 330 | */ |
||
| 331 | public function getOmsStatusInitialized() |
||
| 332 | { |
||
| 333 | return static::OMS_STATUS_INITIALIZED; |
||
| 334 | } |
||
| 335 | |||
| 336 | /** |
||
| 337 | * @api |
||
| 338 | * |
||
| 339 | * @return string |
||
| 340 | */ |
||
| 341 | public function getOmsStatusAuthorized() |
||
| 342 | { |
||
| 343 | return static::OMS_STATUS_AUTHORIZED; |
||
| 344 | } |
||
| 345 | |||
| 346 | /** |
||
| 347 | * @api |
||
| 348 | * |
||
| 349 | * @return string |
||
| 350 | */ |
||
| 351 | public function getOmsStatusConfirmed(): string |
||
| 352 | { |
||
| 353 | return static::OMS_STATUS_CONFIRMED; |
||
| 354 | } |
||
| 355 | |||
| 356 | /** |
||
| 357 | * @api |
||
| 358 | * |
||
| 359 | * @return string |
||
| 360 | */ |
||
| 361 | public function getAuthorizeRequestOmsStatus(): string |
||
| 362 | { |
||
| 363 | return static::OMS_STATUS_AUTHORIZE_REQUEST; |
||
| 364 | } |
||
| 365 | |||
| 366 | /** |
||
| 367 | * @api |
||
| 368 | * |
||
| 369 | * @return string |
||
| 370 | */ |
||
| 371 | public function getOmsStatusAuthorizationFailed() |
||
| 372 | { |
||
| 373 | return static::OMS_STATUS_AUTHORIZATION_FAILED; |
||
| 374 | } |
||
| 375 | |||
| 376 | /** |
||
| 377 | * @api |
||
| 378 | * |
||
| 379 | * @return string |
||
| 380 | */ |
||
| 381 | public function getOmsStatusCaptured() |
||
| 382 | { |
||
| 383 | return static::OMS_STATUS_CAPTURED; |
||
| 384 | } |
||
| 385 | |||
| 386 | /** |
||
| 387 | * @api |
||
| 388 | * |
||
| 389 | * @return string |
||
| 390 | */ |
||
| 391 | public function getOmsStatusCapturingFailed() |
||
| 394 | } |
||
| 395 | |||
| 396 | /** |
||
| 397 | * @api |
||
| 398 | * |
||
| 399 | * @return string |
||
| 400 | */ |
||
| 401 | public function getOmsStatusCancelled() |
||
| 402 | { |
||
| 403 | return static::OMS_STATUS_CANCELLED; |
||
| 404 | } |
||
| 405 | |||
| 406 | /** |
||
| 407 | * @api |
||
| 408 | * |
||
| 409 | * @return string |
||
| 410 | */ |
||
| 411 | public function getOmsStatusRefunded() |
||
| 412 | { |
||
| 413 | return static::OMS_STATUS_REFUNDED; |
||
| 414 | } |
||
| 415 | |||
| 416 | /** |
||
| 417 | * @api |
||
| 418 | * |
||
| 419 | * @return string |
||
| 420 | */ |
||
| 421 | public function getAuthorizeMethodName() |
||
| 424 | } |
||
| 425 | |||
| 426 | /** |
||
| 427 | * @api |
||
| 428 | * |
||
| 429 | * @return string |
||
| 430 | */ |
||
| 431 | public function getCaptureMethodName() |
||
| 432 | { |
||
| 433 | return static::CAPTURE_METHOD; |
||
| 434 | } |
||
| 435 | |||
| 436 | /** |
||
| 437 | * @api |
||
| 438 | * |
||
| 439 | * @return string |
||
| 440 | */ |
||
| 441 | public function getRefundMethodName() |
||
| 442 | { |
||
| 443 | return static::REFUND_METHOD; |
||
| 444 | } |
||
| 445 | |||
| 446 | /** |
||
| 447 | * @api |
||
| 448 | * |
||
| 449 | * @return string |
||
| 450 | */ |
||
| 451 | public function getReverseMethodName() |
||
| 452 | { |
||
| 453 | return static::REVERSE_METHOD; |
||
| 454 | } |
||
| 455 | |||
| 456 | /** |
||
| 457 | * @api |
||
| 458 | * |
||
| 459 | * @return string |
||
| 460 | */ |
||
| 461 | public function getInquireMethodName() |
||
| 462 | { |
||
| 463 | return static::INQUIRE_METHOD; |
||
| 464 | } |
||
| 465 | |||
| 466 | /** |
||
| 467 | * @api |
||
| 468 | * |
||
| 469 | * @return string |
||
| 470 | */ |
||
| 471 | public function getOmsAuthorizeEventName() |
||
| 474 | } |
||
| 475 | |||
| 476 | /** |
||
| 477 | * @api |
||
| 478 | * |
||
| 479 | * @return string |
||
| 480 | */ |
||
| 481 | public function getOmsCaptureEventName() |
||
| 482 | { |
||
| 483 | return static::COMPUTOP_OMS_EVENT_CAPTURE; |
||
| 484 | } |
||
| 485 | |||
| 486 | /** |
||
| 487 | * @api |
||
| 488 | * |
||
| 489 | * @return string[] |
||
| 490 | */ |
||
| 491 | public function getCrifGreenPaymentMethods(): array |
||
| 492 | { |
||
| 493 | return $this->get(ComputopConstants::CRIF_GREEN_AVAILABLE_PAYMENT_METHODS); |
||
| 494 | } |
||
| 495 | |||
| 496 | /** |
||
| 497 | * @api |
||
| 498 | * |
||
| 499 | * @return string[] |
||
| 500 | */ |
||
| 501 | public function getCrifYellowPaymentMethods(): array |
||
| 502 | { |
||
| 503 | return $this->get(ComputopConstants::CRIF_YELLOW_AVAILABLE_PAYMENT_METHODS); |
||
| 504 | } |
||
| 505 | |||
| 506 | /** |
||
| 507 | * @api |
||
| 508 | * |
||
| 509 | * @return string[] |
||
| 510 | */ |
||
| 511 | public function getCrifRedPaymentMethods(): array |
||
| 512 | { |
||
| 513 | return $this->get(ComputopConstants::CRIF_RED_AVAILABLE_PAYMENT_METHODS); |
||
| 514 | } |
||
| 515 | |||
| 516 | /** |
||
| 517 | * @api |
||
| 518 | * |
||
| 519 | * @return bool |
||
| 520 | */ |
||
| 521 | public function isCrifEnabled(): bool |
||
| 522 | { |
||
| 523 | return (bool)$this->get(ComputopConstants::CRIF_ENABLED); |
||
| 524 | } |
||
| 525 | |||
| 526 | /** |
||
| 527 | * @api |
||
| 528 | * |
||
| 529 | * @return string |
||
| 530 | */ |
||
| 531 | public function getEtiId(): string |
||
| 532 | { |
||
| 533 | return SharedComputopConfig::COMPUTOP_MODULE_VERSION; |
||
| 534 | } |
||
| 535 | |||
| 536 | /** |
||
| 537 | * @api |
||
| 538 | * |
||
| 539 | * @return string |
||
| 540 | */ |
||
| 541 | public function getIdealIssuerId(): string |
||
| 544 | } |
||
| 545 | |||
| 546 | /** |
||
| 547 | * Specification: |
||
| 548 | * - Get Available currency for specific payment methods. |
||
| 549 | * |
||
| 550 | * @api |
||
| 551 | * |
||
| 552 | * @return array |
||
| 553 | */ |
||
| 554 | public function getComputopPaymentMethodCurrencyFilterMap(): array |
||
| 555 | { |
||
| 556 | return [ |
||
| 557 | SharedComputopConfig::PAYMENT_METHOD_PAYU_CEE_SINGLE => [ |
||
| 558 | 'PLN', |
||
| 559 | 'CZK', |
||
| 560 | ], |
||
| 561 | ]; |
||
| 562 | } |
||
| 563 | } |
||
| 564 |