Passed
Push — feature/eco-3623-payone-pay-u-... ( acd9a9...8799f8 )
by Roman
06:13
created

setDefaultPaymentToQuote()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 12
rs 10
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\Computop\Form\DataProvider;
9
10
use Generated\Shared\Transfer\ComputopPayuCeeSinglePaymentTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...eeSinglePaymentTransfer 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\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...
12
use Generated\Shared\Transfer\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...
13
use Spryker\Shared\Kernel\Transfer\AbstractTransfer;
14
15
class PayuCeeSingleFormDataProvider extends AbstractFormDataProvider
16
{
17
    /**
18
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
19
     *
20
     * @return \Generated\Shared\Transfer\QuoteTransfer
21
     */
22
    public function getData(AbstractTransfer $quoteTransfer): AbstractTransfer
23
    {
24
        /** @var \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer */
25
        if ($quoteTransfer->getPayment() === null) {
26
            $quoteTransfer->setPayment(new PaymentTransfer());
27
28
            return $quoteTransfer;
29
        }
30
31
        if ($this->isValidPayment($quoteTransfer)) {
32
            return $quoteTransfer;
33
        }
34
35
        return $this->setDefaultPaymentToQuote($quoteTransfer);
36
    }
37
38
    /**
39
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
40
     *
41
     * @return \Generated\Shared\Transfer\ComputopPayuCeeSinglePaymentTransfer|null
42
     */
43
    protected function getComputopPayment(QuoteTransfer $quoteTransfer): ?ComputopPayuCeeSinglePaymentTransfer
44
    {
45
        return $quoteTransfer->getPayment()->getComputopPayuCeeSingle();
46
    }
47
48
    /**
49
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
50
     *
51
     * @return \Generated\Shared\Transfer\QuoteTransfer
52
     */
53
    protected function setDefaultPaymentToQuote(QuoteTransfer $quoteTransfer): QuoteTransfer
54
    {
55
        /** @var \Generated\Shared\Transfer\ComputopPayuCeeSinglePaymentTransfer $computopTransfer */
56
        $computopTransfer = $this->mapper->createComputopPaymentTransfer($quoteTransfer);
57
58
        $paymentTransfer = $quoteTransfer->getPayment();
59
        $paymentTransfer->setComputopPayuCeeSingle($computopTransfer);
60
61
        $quoteTransfer->setPayment($paymentTransfer);
62
        $this->quoteClient->setQuote($quoteTransfer);
63
64
        return $quoteTransfer;
65
    }
66
}
67