Passed
Pull Request — master (#23)
by Volodymyr
48:37
created

BancontactOnlineTransferDataProvider::getOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
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\Yves\Payone\Form\DataProvider;
9
10
use Generated\Shared\Transfer\PaymentTransfer;
11
use Generated\Shared\Transfer\PayonePaymentTransfer;
12
use Spryker\Shared\Kernel\Transfer\AbstractTransfer;
13
use Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface;
14
use SprykerEco\Yves\Payone\Form\BancontactOnlineTransferSubForm;
15
use SprykerEco\Yves\Payone\PayoneConfig;
16
17
class BancontactOnlineTransferDataProvider implements StepEngineFormDataProviderInterface
18
{
19
    /**
20
     * @var \SprykerEco\Yves\Payone\PayoneConfig
21
     */
22
    protected $config;
23
24
    /**
25
     * @param \SprykerEco\Yves\Payone\PayoneConfig $config
26
     */
27
    public function __construct(PayoneConfig $config)
28
    {
29
        $this->config = $config;
30
    }
31
32
    /**
33
     * @param \Spryker\Shared\Kernel\Transfer\AbstractTransfer|\Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
34
     *
35
     * @return \Spryker\Shared\Kernel\Transfer\AbstractTransfer
36
     */
37
    public function getData(AbstractTransfer $quoteTransfer): AbstractTransfer
38
    {
39
        if ($quoteTransfer->getPayment() !== null) {
0 ignored issues
show
Bug introduced by
The method getPayment() does not seem to exist on object<Spryker\Shared\Ke...nsfer\AbstractTransfer>.

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...
40
            return $quoteTransfer;
41
        }
42
43
        $paymentTransfer = new PaymentTransfer();
44
        $paymentTransfer->setPayone(new PayonePaymentTransfer());
45
        $quoteTransfer->setPayment($paymentTransfer);
0 ignored issues
show
Bug introduced by
The method setPayment() does not seem to exist on object<Spryker\Shared\Ke...nsfer\AbstractTransfer>.

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...
46
47
        return $quoteTransfer;
48
    }
49
50
    /**
51
     * @param \Spryker\Shared\Kernel\Transfer\AbstractTransfer $quoteTransfer
52
     *
53
     * @return array
54
     */
55
    public function getOptions(AbstractTransfer $quoteTransfer): array
56
    {
57
        return [
58
            BancontactOnlineTransferSubForm::OPTION_BANK_COUNTRIES => $this->getBankCountries(),
59
        ];
60
    }
61
62
    /**
63
     * @return array
64
     */
65
    protected function getBankCountries(): array
66
    {
67
        return $this->config->getPayOneBancontactAvailableCountries();
68
    }
69
}
70