Passed
Push — master ( a8446e...164738 )
by
unknown
13:26
created

DirectDebitDataProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getOptions() 0 5 1
A __construct() 0 3 1
A getData() 0 10 2
A getBankAccountModes() 0 5 1
A getBankCountries() 0 5 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\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\Dependency\Client\PayoneToStoreClientInterface;
15
use SprykerEco\Yves\Payone\Form\DirectDebitSubForm;
16
17
class DirectDebitDataProvider implements StepEngineFormDataProviderInterface
18
{
19
    /**
20
     * @var \SprykerEco\Yves\Payone\Dependency\Client\PayoneToStoreClientInterface
21
     */
22
    private $storeClient;
23
24
    /**
25
     * @param \SprykerEco\Yves\Payone\Dependency\Client\PayoneToStoreClientInterface $storeClient
26
     */
27
    public function __construct(PayoneToStoreClientInterface $storeClient)
28
    {
29
        $this->storeClient = $storeClient;
30
    }
31
32
    /**
33
     * @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...
34
     *
35
     * @return \Spryker\Shared\Kernel\Transfer\AbstractTransfer
36
     */
37
    public function getData(AbstractTransfer $quoteTransfer)
38
    {
39
        /** @var \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer */
40
        if ($quoteTransfer->getPayment() === null) {
41
            $paymentTransfer = new PaymentTransfer();
42
            $paymentTransfer->setPayone(new PayonePaymentTransfer());
43
            $quoteTransfer->setPayment($paymentTransfer);
44
        }
45
46
        return $quoteTransfer;
47
    }
48
49
    /**
50
     * @param \Spryker\Shared\Kernel\Transfer\AbstractTransfer $quoteTransfer
51
     *
52
     * @return array
53
     */
54
    public function getOptions(AbstractTransfer $quoteTransfer)
55
    {
56
        return [
57
            DirectDebitSubForm::OPTION_BANK_COUNTRIES => $this->getBankCountries(),
58
            DirectDebitSubForm::OPTION_BANK_ACCOUNT_MODE => $this->getBankAccountModes(),
59
        ];
60
    }
61
62
    /**
63
     * @return array<string, string>
64
     */
65
    protected function getBankCountries(): array
66
    {
67
        $countries = $this->storeClient->getCurrentStore()->getCountries();
68
69
        return array_combine($countries, $countries);
70
    }
71
72
    /**
73
     * @return array
74
     */
75
    protected function getBankAccountModes()
76
    {
77
        return [
78
            'BBAN' => 'BBAN',
79
            'IBAN/BIC' => 'IBAN/BIC',
80
        ];
81
    }
82
}
83