CreditCardDataProvider   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 39
c 3
b 0
f 0
dl 0
loc 89
rs 10
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getOptions() 0 6 1
A getMonthChoices() 0 15 1
A getYearChoices() 0 10 2
A getCardTypes() 0 12 1
A getData() 0 10 2
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\Payone\Form\DataProvider;
9
10
use Generated\Shared\Transfer\PaymentTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PaymentTransfer 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\PayonePaymentTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PayonePaymentTransfer 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 Spryker\Shared\Kernel\Transfer\AbstractTransfer;
13
use Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface;
14
use SprykerEco\Yves\Payone\Form\CreditCardSubForm;
15
16
class CreditCardDataProvider implements StepEngineFormDataProviderInterface
17
{
18
    /**
19
     * @const int YEAR_CHOICES_AMOUNT
20
     */
21
    public const YEAR_CHOICES_AMOUNT = 20;
22
23
    /**
24
     * @param \Spryker\Shared\Kernel\Transfer\AbstractTransfer|\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...
25
     *
26
     * @return \Spryker\Shared\Kernel\Transfer\AbstractTransfer
27
     */
28
    public function getData(AbstractTransfer $quoteTransfer)
29
    {
30
        /** @var \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer */
31
        if ($quoteTransfer->getPayment() === null) {
32
            $paymentTransfer = new PaymentTransfer();
33
            $paymentTransfer->setPayone(new PayonePaymentTransfer());
34
            $quoteTransfer->setPayment($paymentTransfer);
35
        }
36
37
        return $quoteTransfer;
38
    }
39
40
    /**
41
     * @param \Spryker\Shared\Kernel\Transfer\AbstractTransfer $quoteTransfer
42
     *
43
     * @return array
44
     */
45
    public function getOptions(AbstractTransfer $quoteTransfer)
46
    {
47
        return [
48
            CreditCardSubForm::OPTION_CARD_EXPIRES_CHOICES_MONTH => $this->getMonthChoices(),
49
            CreditCardSubForm::OPTION_CARD_EXPIRES_CHOICES_YEAR => $this->getYearChoices(),
50
            CreditCardSubForm::OPTION_CARD_TYPES => $this->getCardTypes(),
51
        ];
52
    }
53
54
    /**
55
     * @return array
56
     */
57
    protected function getMonthChoices()
58
    {
59
        return [
60
            '01' => '01',
61
            '02' => '02',
62
            '03' => '03',
63
            '04' => '04',
64
            '05' => '05',
65
            '06' => '06',
66
            '07' => '07',
67
            '08' => '08',
68
            '09' => '09',
69
            '10' => '10',
70
            '11' => '11',
71
            '12' => '12',
72
        ];
73
    }
74
75
    /**
76
     * @return array
77
     */
78
    protected function getYearChoices()
79
    {
80
        $result = [];
81
        $currentYear = date('Y');
82
83
        for ($i = 0; $i < self::YEAR_CHOICES_AMOUNT; $i++) {
84
            $result[$currentYear] = $currentYear++;
85
        }
86
87
        return $result;
88
    }
89
90
    /**
91
     * @return array
92
     */
93
    protected function getCardTypes()
94
    {
95
        return [
96
            'Visa' => 'V',
97
            'Master Card' => 'M',
98
            'American Express' => 'A',
99
            'Diners' => 'D',
100
            'JCB' => 'J',
101
            'Maestro International' => 'O',
102
            'Maestro UK' => 'U',
103
            'Discover' => 'C',
104
            'Carte Bleue' => 'B',
105
        ];
106
    }
107
}
108