Code Duplication    Length = 26-27 lines in 3 locations

src/SprykerEco/Zed/Payone/Business/Payment/PaymentManager.php 3 locations

@@ 399-425 (lines=27) @@
396
     *
397
     * @return \Generated\Shared\Transfer\PayoneGetFileTransfer
398
     */
399
    public function getFile(PayoneGetFileTransfer $getFileTransfer)
400
    {
401
        $responseContainer = new GetFileResponseContainer();
402
        $paymentEntity = $this->findPaymentByFileReferenceAndCustomerId(
403
            $getFileTransfer->getReference(),
404
            $getFileTransfer->getCustomerId()
405
        );
406
407
        if ($paymentEntity) {
408
            /** @var \SprykerEco\Zed\Payone\Business\Payment\MethodMapper\DirectDebit $paymentMethodMapper */
409
            $paymentMethodMapper = $this->getRegisteredPaymentMethodMapper(PayoneApiConstants::PAYMENT_METHOD_DIRECT_DEBIT);
410
            $requestContainer = $paymentMethodMapper->mapGetFile($getFileTransfer);
411
            $this->setStandardParameter($requestContainer);
412
            $rawResponse = $this->executionAdapter->sendRequest($requestContainer);
413
            $responseContainer->init($rawResponse);
414
        } else {
415
            $this->setAccessDeniedError($responseContainer);
416
        }
417
418
        $getFileTransfer->setRawResponse($responseContainer->getRawResponse());
419
        $getFileTransfer->setStatus($responseContainer->getStatus());
420
        $getFileTransfer->setErrorCode($responseContainer->getErrorcode());
421
        $getFileTransfer->setCustomerErrorMessage($responseContainer->getCustomermessage());
422
        $getFileTransfer->setInternalErrorMessage($responseContainer->getErrormessage());
423
424
        return $getFileTransfer;
425
    }
426
427
    /**
428
     * @param \Generated\Shared\Transfer\PayoneGetInvoiceTransfer $getInvoiceTransfer
@@ 432-457 (lines=26) @@
429
     *
430
     * @return \Generated\Shared\Transfer\PayoneGetInvoiceTransfer
431
     */
432
    public function getInvoice(PayoneGetInvoiceTransfer $getInvoiceTransfer)
433
    {
434
        $responseContainer = new GetInvoiceResponseContainer();
435
        $paymentEntity = $this->findPaymentByInvoiceTitleAndCustomerId(
436
            $getInvoiceTransfer->getReference(),
437
            $getInvoiceTransfer->getCustomerId()
438
        );
439
440
        if ($paymentEntity) {
441
            /** @var \SprykerEco\Zed\Payone\Business\Payment\MethodMapper\Invoice $paymentMethodMapper */
442
            $paymentMethodMapper = $this->getRegisteredPaymentMethodMapper(PayoneApiConstants::PAYMENT_METHOD_INVOICE);
443
            $requestContainer = $paymentMethodMapper->mapGetInvoice($getInvoiceTransfer);
444
            $this->setStandardParameter($requestContainer);
445
            $rawResponse = $this->executionAdapter->sendRequest($requestContainer);
446
            $responseContainer->init($rawResponse);
447
        } else {
448
            $this->setAccessDeniedError($responseContainer);
449
        }
450
451
        $getInvoiceTransfer->setRawResponse($responseContainer->getRawResponse());
452
        $getInvoiceTransfer->setStatus($responseContainer->getStatus());
453
        $getInvoiceTransfer->setErrorCode($responseContainer->getErrorcode());
454
        $getInvoiceTransfer->setInternalErrorMessage($responseContainer->getErrormessage());
455
456
        return $getInvoiceTransfer;
457
    }
458
459
    /**
460
     * @param \Generated\Shared\Transfer\PayoneGetSecurityInvoiceTransfer $getSecurityInvoiceTransfer
@@ 464-489 (lines=26) @@
461
     *
462
     * @return \Generated\Shared\Transfer\PayoneGetSecurityInvoiceTransfer
463
     */
464
    public function getSecurityInvoice(PayoneGetSecurityInvoiceTransfer $getSecurityInvoiceTransfer)
465
    {
466
        $responseContainer = new GetSecurityInvoiceResponseContainer();
467
        $paymentEntity = $this->findPaymentByInvoiceTitleAndCustomerId(
468
            $getSecurityInvoiceTransfer->getReference(),
469
            $getSecurityInvoiceTransfer->getCustomerId()
470
        );
471
472
        if ($paymentEntity) {
473
            /** @var \SprykerEco\Zed\Payone\Business\Payment\MethodMapper\Invoice $paymentMethodMapper */
474
            $paymentMethodMapper = $this->getRegisteredPaymentMethodMapper(PayoneApiConstants::PAYMENT_METHOD_SECURITY_INVOICE);
475
            $requestContainer = $paymentMethodMapper->mapGetSecurityInvoice($getSecurityInvoiceTransfer);
476
            $this->setStandardParameter($requestContainer);
477
            $rawResponse = $this->executionAdapter->sendRequest($requestContainer);
478
            $responseContainer->init($rawResponse);
479
        } else {
480
            $this->setAccessDeniedError($responseContainer);
481
        }
482
483
        $getSecurityInvoiceTransfer->setRawResponse($responseContainer->getRawResponse());
484
        $getSecurityInvoiceTransfer->setStatus($responseContainer->getStatus());
485
        $getSecurityInvoiceTransfer->setErrorCode($responseContainer->getErrorcode());
486
        $getSecurityInvoiceTransfer->setInternalErrorMessage($responseContainer->getErrormessage());
487
488
        return $getSecurityInvoiceTransfer;
489
    }
490
491
    /**
492
     * @param int $transactionId