Installment   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 114
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 30
c 1
b 0
f 0
dl 0
loc 114
rs 10
wmc 9

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getMethodName() 0 3 1
A mapPaymentData() 0 12 2
A getPaymentData() 0 7 1
A calculationRequest() 0 11 1
A getPaymentTransferObject() 0 3 1
A mapConfigurationData() 0 3 1
A mapCalculationData() 0 7 1
A configurationRequest() 0 11 1
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Ratepay\Business\Request\Payment\Method;
9
10
use Generated\Shared\Transfer\QuoteTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\QuoteTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Generated\Shared\Transfer\RatepayPaymentInstallmentTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...mentInstallmentTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Generated\Shared\Transfer\RatepayPaymentRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...yPaymentRequestTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use SprykerEco\Shared\Ratepay\RatepayConfig;
14
use SprykerEco\Zed\Ratepay\Business\Api\Constants as ApiConstants;
15
16
/**
17
 * Ratepay Elv payment method.
18
 */
19
class Installment extends AbstractMethod
20
{
21
    /**
22
     * @return string
23
     */
24
    public function getMethodName()
25
    {
26
        return RatepayConfig::INSTALLMENT;
27
    }
28
29
    /**
30
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
31
     *
32
     * @return \Generated\Shared\Transfer\RatepayPaymentInstallmentTransfer
33
     */
34
    public function getPaymentData(QuoteTransfer $quoteTransfer)
35
    {
36
        return $quoteTransfer
37
            ->requirePayment()
38
            ->getPayment()
39
            ->requireRatepayInstallment()
40
            ->getRatepayInstallment();
41
    }
42
43
    /**
44
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
45
     *
46
     * @return \SprykerEco\Zed\Ratepay\Business\Api\Model\Payment\Request
47
     */
48
    public function configurationRequest(QuoteTransfer $quoteTransfer)
49
    {
50
        $paymentData = $this->getPaymentData($quoteTransfer);
51
52
        /*
53
         * @var \SprykerEco\Zed\Ratepay\Business\Api\Model\Payment\Request $request
54
         */
55
        $request = $this->modelFactory->build(ApiConstants::REQUEST_MODEL_CONFIGURATION_REQUEST);
56
        $this->mapConfigurationData($quoteTransfer, $paymentData);
57
58
        return $request;
59
    }
60
61
    /**
62
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
63
     *
64
     * @return \SprykerEco\Zed\Ratepay\Business\Api\Model\Payment\Calculation
65
     */
66
    public function calculationRequest(QuoteTransfer $quoteTransfer)
67
    {
68
        $paymentData = $this->getPaymentData($quoteTransfer);
69
70
        /*
71
         * @var \SprykerEco\Zed\Ratepay\Business\Api\Model\Payment\Calculation $request
72
         */
73
        $request = $this->modelFactory->build(ApiConstants::REQUEST_MODEL_CALCULATION_REQUEST);
74
        $this->mapCalculationData($quoteTransfer, $paymentData);
75
76
        return $request;
77
    }
78
79
    /**
80
     * @param \Generated\Shared\Transfer\RatepayPaymentRequestTransfer $ratepayPaymentRequestTransfer
81
     *
82
     * @return void
83
     */
84
    protected function mapPaymentData(RatepayPaymentRequestTransfer $ratepayPaymentRequestTransfer)
85
    {
86
        parent::mapPaymentData($ratepayPaymentRequestTransfer);
87
88
        $this->mapperFactory
89
            ->createInstallmentPaymentMapper($ratepayPaymentRequestTransfer)
90
            ->map();
91
        $this->mapperFactory
92
            ->createInstallmentDetailMapper($ratepayPaymentRequestTransfer)
93
            ->map();
94
        if ($ratepayPaymentRequestTransfer->getDebitPayType() == RatepayConfig::DEBIT_PAY_TYPE_DIRECT_DEBIT) {
95
            $this->mapBankAccountData($ratepayPaymentRequestTransfer);
96
        }
97
    }
98
99
    /**
100
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
101
     * @param \Generated\Shared\Transfer\RatepayPaymentInstallmentTransfer $paymentData
102
     *
103
     * @return void
104
     */
105
    protected function mapConfigurationData($quoteTransfer, $paymentData)
106
    {
107
        $this->mapperFactory->createQuoteHeadMapper($quoteTransfer, $paymentData)->map();
108
    }
109
110
    /**
111
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
112
     * @param \Generated\Shared\Transfer\RatepayPaymentInstallmentTransfer $paymentData
113
     *
114
     * @return void
115
     */
116
    protected function mapCalculationData($quoteTransfer, $paymentData)
117
    {
118
        $this->mapperFactory->createQuoteHeadMapper($quoteTransfer, $paymentData)->map();
119
120
        $this->mapperFactory
121
            ->createInstallmentCalculationMapper($quoteTransfer, $paymentData)
122
            ->map();
123
    }
124
125
    /**
126
     * @param \Orm\Zed\Ratepay\Persistence\SpyPaymentRatepay $payment
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Ratepay\Persistence\SpyPaymentRatepay was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
127
     *
128
     * @return \Generated\Shared\Transfer\RatepayPaymentInstallmentTransfer
129
     */
130
    protected function getPaymentTransferObject($payment)
131
    {
132
        return new RatepayPaymentInstallmentTransfer();
133
    }
134
}
135