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

HeidelpayCreditCardHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 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\Heidelpay\Handler;
9
10
use Spryker\Client\Calculation\CalculationClientInterface;
11
use Spryker\Client\Quote\QuoteClientInterface;
12
use Spryker\Shared\Kernel\Transfer\AbstractTransfer;
13
use SprykerEco\Shared\Heidelpay\HeidelpayConfig;
14
15
class HeidelpayCreditCardHandler extends HeidelpayHandler
16
{
17
    const PAYMENT_PROVIDER = HeidelpayConfig::PROVIDER_NAME;
18
    const CHECKOUT_PARTIAL_SUMMARY_PATH = 'Heidelpay/partial/summary';
19
20
    /**
21
     * @var \Spryker\Client\Calculation\CalculationClientInterface
22
     */
23
    protected $calculationClient;
24
25
    /**
26
     * @var \Spryker\Client\Quote\QuoteClientInterface
27
     */
28
    protected $quoteClient;
29
30
    /**
31
     * @var array
32
     */
33
    protected static $paymentMethods = [
34
        HeidelpayConfig::PAYMENT_METHOD_PAYPAL_AUTHORIZE => HeidelpayConfig::PAYMENT_METHOD_PAYPAL_AUTHORIZE,
35
        HeidelpayConfig::PAYMENT_METHOD_CREDIT_CARD_SECURE => HeidelpayConfig::PAYMENT_METHOD_CREDIT_CARD_SECURE,
36
        HeidelpayConfig::PAYMENT_METHOD_IDEAL => HeidelpayConfig::PAYMENT_METHOD_IDEAL,
37
        HeidelpayConfig::PAYMENT_METHOD_SOFORT => HeidelpayConfig::PAYMENT_METHOD_SOFORT,
38
    ];
39
40
    /**
41
     * @param \Spryker\Client\Calculation\CalculationClientInterface $calculationClient
42
     * @param \Spryker\Client\Quote\QuoteClientInterface $quoteClient
43
     */
44
    public function __construct(
45
        CalculationClientInterface $calculationClient,
46
        QuoteClientInterface $quoteClient
47
    ) {
48
        $this->calculationClient = $calculationClient;
49
        $this->quoteClient = $quoteClient;
50
    }
51
52
    /**
53
     * @param \Spryker\Shared\Kernel\Transfer\AbstractTransfer|\Generated\Shared\Transfer\QuoteTransfer $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...
54
     *
55
     * @return \Spryker\Shared\Kernel\Transfer\AbstractTransfer
56
     */
57
    public function addPaymentToQuote(AbstractTransfer $quoteTransfer)
58
    {
59
        $quoteTransfer = parent::addPaymentToQuote($quoteTransfer);
60
        $this->addCurrentRegistrationToQuote($quoteTransfer);
61
        $quoteTransfer = $this->calculationClient->recalculate($quoteTransfer);
62
        $this->quoteClient->setQuote($quoteTransfer);
63
        return $quoteTransfer;
64
    }
65
66
    /**
67
     * @param \Spryker\Shared\Kernel\Transfer\AbstractTransfer|\Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
68
     *
69
     * @return void
70
     */
71
    protected function addCurrentRegistrationToQuote(AbstractTransfer $quoteTransfer)
72
    {
73
        $creditCardPayment = $quoteTransfer->getPayment()->getHeidelpayCreditCardSecure();
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

73
        $creditCardPayment = $quoteTransfer->/** @scrutinizer ignore-call */ getPayment()->getHeidelpayCreditCardSecure();

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...
74
        $paymentOption = $creditCardPayment->getSelectedPaymentOption();
75
76
        if ($paymentOption === HeidelpayConfig::PAYMENT_OPTION_EXISTING_REGISTRATION) {
77
            $creditCardPayment->setSelectedRegistration(
78
                $creditCardPayment->getPaymentOptions()->getLastSuccessfulRegistration()
79
            );
80
        }
81
    }
82
}
83