ComputopPayNowInitStep   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 38
c 1
b 0
f 0
dl 0
loc 82
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A requireInput() 0 10 3
A getBrandOptions() 0 34 1
A postCondition() 0 3 1
A getTemplateVariables() 0 8 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\Yves\Computop\CheckoutPage\Process\Steps;
9
10
use Spryker\Shared\Kernel\Transfer\AbstractTransfer;
11
use SprykerEco\Shared\Computop\ComputopConfig;
12
use SprykerShop\Yves\CheckoutPage\Process\Steps\AbstractBaseStep;
13
14
class ComputopPayNowInitStep extends AbstractBaseStep
15
{
16
    /**
17
     * @param \Generated\Shared\Transfer\QuoteTransfer $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...
18
     *
19
     * @return bool
20
     */
21
    public function requireInput(AbstractTransfer $quoteTransfer): bool
22
    {
23
        if (
24
            !$quoteTransfer->getPayment()
0 ignored issues
show
Bug introduced by
The method getPayment() does not exist on Spryker\Shared\Kernel\Transfer\AbstractTransfer. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
            !$quoteTransfer->/** @scrutinizer ignore-call */ getPayment()

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
25
            || $quoteTransfer->getPayment()->getPaymentSelection() !== ComputopConfig::PAYMENT_METHOD_PAY_NOW
26
        ) {
27
            return false;
28
        }
29
30
        return true;
31
    }
32
33
    /**
34
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
35
     *
36
     * @return bool
37
     */
38
    public function postCondition(AbstractTransfer $quoteTransfer): bool
39
    {
40
        return true;
41
    }
42
43
    /**
44
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
45
     *
46
     * @return array
47
     */
48
    public function getTemplateVariables(AbstractTransfer $quoteTransfer): array
49
    {
50
        return [
51
            'formAction' => $quoteTransfer->getPayment()->getComputopPayNow()->getUrl(),
52
            'encryptedData' => $quoteTransfer->getPayment()->getComputopPayNow()->getData(),
53
            'encryptedDataLength' => $quoteTransfer->getPayment()->getComputopPayNow()->getLen(),
54
            'merchantId' => $quoteTransfer->getPayment()->getComputopPayNow()->getMerchantId(),
55
            'brandOptions' => $this->getBrandOptions(),
56
        ];
57
    }
58
59
    /**
60
     * @return string[][]
61
     */
62
    protected function getBrandOptions(): array
63
    {
64
        return [
65
            'VISA' => [
66
                'value' => 'VISA',
67
                'label' => 'Visa',
68
            ],
69
            'MasterCard' => [
70
                'value' => 'MasterCard',
71
                'label' => 'Master Card',
72
            ],
73
            'AMEX' => [
74
                'value' => 'AMEX',
75
                'label' => 'American Express',
76
            ],
77
            'DINERS' => [
78
                'value' => 'DINERS',
79
                'label' => 'Diners Club',
80
            ],
81
            'JCB' => [
82
                'value' => 'JCB',
83
                'label' => 'JCB',
84
            ],
85
            'CBN' => [
86
                'value' => 'CBN',
87
                'label' => 'CBN',
88
            ],
89
            'SWITCH' => [
90
                'value' => 'SWITCH',
91
                'label' => 'Switch',
92
            ],
93
            'SOLO' => [
94
                'value' => 'SOLO',
95
                'label' => 'Solo',
96
            ],
97
        ];
98
    }
99
}
100