Completed
Push — master ( b01f25...f0c935 )
by Oleksandr
12s
created

HeidelpayClient::filterResponseParameters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 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\Client\Heidelpay;
9
10
use Generated\Shared\Transfer\HeidelpayExternalPaymentRequestTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...lPaymentRequestTransfer 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\HeidelpayRegistrationByIdAndQuoteRequestTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...AndQuoteRequestTransfer 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\HeidelpayRegistrationRequestTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...strationRequestTransfer 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 Generated\Shared\Transfer\QuoteTransfer;
1 ignored issue
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...
14
use Spryker\Client\Kernel\AbstractClient;
15
16
/**
17
 * @method \SprykerEco\Client\Heidelpay\HeidelpayFactory getFactory()
18
 */
19
class HeidelpayClient extends AbstractClient implements HeidelpayClientInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     *
24
     * @api
25
     *
26
     * @param string $errorCode
27
     *
28
     * @return string
29
     */
30
    public function translateErrorMessageByCode($errorCode)
31
    {
32
        $currentLocale = $this->getCurrentLocale();
33
34
        return $this->getFactory()
35
            ->createHeidelpayApiAdapter()
36
            ->getTranslatedMessageByCode($errorCode, $currentLocale);
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     *
42
     * @api
43
     *
44
     * @param string $orderReference
45
     *
46
     * @return \Generated\Shared\Transfer\HeidelpayTransactionLogTransfer
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...yTransactionLogTransfer 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...
47
     */
48
    public function getAuthorizeTransactionLogForOrder($orderReference)
49
    {
50
        return $this->getFactory()
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getFactory...erence($orderReference) returns the type Spryker\Shared\Kernel\Transfer\TransferInterface which is incompatible with the documented return type Generated\Shared\Transfe...yTransactionLogTransfer.
Loading history...
51
            ->createZedStub()
52
            ->getAuthorizeTransactionLogByOrderReference($orderReference);
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     *
58
     * @api
59
     *
60
     * @return \Generated\Shared\Transfer\QuoteTransfer
61
     */
62
    public function getQuoteFromSession()
63
    {
64
        return $this->getFactory()
65
            ->getQuoteClient()
66
            ->getQuote();
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     *
72
     * @api
73
     *
74
     * @param array $externalResponse
75
     *
76
     * @return \Generated\Shared\Transfer\HeidelpayRegistrationRequestTransfer
77
     */
78
    public function parseExternalResponse(array $externalResponse)
79
    {
80
        return $this->getFactory()
81
            ->createExternalResponseValidator()
82
            ->parseExternalResponse($externalResponse);
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     *
88
     * @api
89
     *
90
     * @param array $externalResponse
91
     *
92
     * @return \Generated\Shared\Transfer\HeidelpayPaymentProcessingResponseTransfer
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...cessingResponseTransfer 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...
93
     */
94
    public function processExternalPaymentResponse(array $externalResponse)
95
    {
96
        $externalResponseTransfer = $this->buildTransferFromExternalResponseArray($externalResponse);
97
98
        return $this->getFactory()
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getFactory...ternalResponseTransfer) returns the type Spryker\Shared\Kernel\Transfer\TransferInterface which is incompatible with the documented return type Generated\Shared\Transfe...cessingResponseTransfer.
Loading history...
99
            ->createZedStub()
100
            ->processExternalPaymentResponse($externalResponseTransfer);
101
    }
102
103
    /**
104
     * {@inheritdoc}
105
     *
106
     * @api
107
     *
108
     * @param \Generated\Shared\Transfer\HeidelpayRegistrationRequestTransfer $registrationRequestTransfer
109
     *
110
     * @return \Generated\Shared\Transfer\HeidelpayRegistrationSaveResponseTransfer
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...ionSaveResponseTransfer 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...
111
     */
112
    public function saveCreditCardRegistration(HeidelpayRegistrationRequestTransfer $registrationRequestTransfer)
113
    {
114
        return $this->getFactory()
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getFactory...trationRequestTransfer) returns the type Spryker\Shared\Kernel\Transfer\TransferInterface which is incompatible with the documented return type Generated\Shared\Transfe...ionSaveResponseTransfer.
Loading history...
115
            ->createZedStub()
116
            ->saveCreditCardRegistration($registrationRequestTransfer);
117
    }
118
119
    /**
120
     * {@inheritdoc}
121
     *
122
     * @api
123
     *
124
     * @param int $idRegistration
125
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
126
     *
127
     * @return \Generated\Shared\Transfer\HeidelpayCreditCardRegistrationTransfer|null
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...ardRegistrationTransfer 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...
128
     */
129
    public function findRegistrationByIdAndQuote($idRegistration, QuoteTransfer $quoteTransfer)
130
    {
131
        $findRegistrationRequestTransfer = $this->buildFindRegistrationRequestTransfer($idRegistration, $quoteTransfer);
132
133
        return $this->getFactory()
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getFactory...trationRequestTransfer) returns the type Spryker\Shared\Kernel\Transfer\TransferInterface which is incompatible with the documented return type null|Generated\Shared\Tr...ardRegistrationTransfer.
Loading history...
134
            ->createZedStub()
135
            ->findCreditCardRegistrationByIdAndQuote($findRegistrationRequestTransfer);
136
    }
137
138
    /**
139
     * {@inheritdoc}
140
     *
141
     * @api
142
     *
143
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
144
     *
145
     * @return \Generated\Shared\Transfer\HeidelpayCreditCardPaymentOptionsTransfer
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...dPaymentOptionsTransfer 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...
146
     */
147
    public function getCreditCardPaymentOptions(QuoteTransfer $quoteTransfer)
148
    {
149
        return $this->getFactory()
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getFactory...Options($quoteTransfer) returns the type Spryker\Shared\Kernel\Transfer\TransferInterface which is incompatible with the documented return type Generated\Shared\Transfe...dPaymentOptionsTransfer.
Loading history...
150
            ->createZedStub()
151
            ->getCreditCardPaymentOptions($quoteTransfer);
152
    }
153
154
    /**
155
     * {@inheritdoc}
156
     *
157
     * @api
158
     *
159
     * @param array $responseArray
160
     *
161
     * @return array
162
     */
163
    public function filterResponseParameters(array $responseArray)
164
    {
165
        return array_filter($responseArray, function ($key) {
166
            return !preg_match('/^paymentForm+|^lang+/', $key);
167
        }, ARRAY_FILTER_USE_KEY);
168
    }
169
170
    /**
171
     * @return string
172
     */
173
    protected function getCurrentLocale()
174
    {
175
        return $this->getFactory()
176
            ->getLocaleClient()
177
            ->getCurrentLocale();
178
    }
179
180
    /**
181
     * @param array $externalResponse
182
     *
183
     * @return \Generated\Shared\Transfer\HeidelpayExternalPaymentRequestTransfer
184
     */
185
    protected function buildTransferFromExternalResponseArray(array $externalResponse)
186
    {
187
        return (new HeidelpayExternalPaymentRequestTransfer())
188
            ->setBody($externalResponse);
189
    }
190
191
    /**
192
     * @param int $idRegistration
193
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
194
     *
195
     * @return \Generated\Shared\Transfer\HeidelpayRegistrationByIdAndQuoteRequestTransfer
196
     */
197
    protected function buildFindRegistrationRequestTransfer($idRegistration, QuoteTransfer $quoteTransfer)
198
    {
199
        return (new HeidelpayRegistrationByIdAndQuoteRequestTransfer())
200
            ->setIdRegistration($idRegistration)
201
            ->setQuote($quoteTransfer);
202
    }
203
}
204