SofortFormDataProvider::getData()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
eloc 10
c 4
b 1
f 0
dl 0
loc 16
rs 9.9332
cc 3
nc 4
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\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\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...
12
use Spryker\Shared\Kernel\Transfer\AbstractTransfer;
13
14
class SofortFormDataProvider extends AbstractFormDataProvider
15
{
16
    /**
17
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
18
     *
19
     * @return \Generated\Shared\Transfer\QuoteTransfer
20
     */
21
    public function getData(AbstractTransfer $quoteTransfer)
22
    {
23
        if ($quoteTransfer->getPayment() === null) {
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

23
        if ($quoteTransfer->/** @scrutinizer ignore-call */ getPayment() === null) {

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...
24
            $paymentTransfer = new PaymentTransfer();
25
            $quoteTransfer->setPayment($paymentTransfer);
0 ignored issues
show
Bug introduced by
The method setPayment() 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

25
            $quoteTransfer->/** @scrutinizer ignore-call */ 
26
                            setPayment($paymentTransfer);

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...
26
        }
27
28
        if (!$this->isValidPayment($quoteTransfer)) {
29
            $paymentTransfer = $quoteTransfer->getPayment();
30
            $computopTransfer = $this->mapper->createComputopPaymentTransfer($quoteTransfer);
31
            $paymentTransfer->setComputopSofort($computopTransfer);
32
            $quoteTransfer->setPayment($paymentTransfer);
33
            $this->quoteClient->setQuote($quoteTransfer);
34
        }
35
36
        return $quoteTransfer;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $quoteTransfer returns the type Spryker\Shared\Kernel\Transfer\AbstractTransfer which is incompatible with the documented return type Generated\Shared\Transfer\QuoteTransfer.
Loading history...
37
    }
38
39
    /**
40
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
41
     *
42
     * @return \Spryker\Shared\Kernel\Transfer\TransferInterface
43
     */
44
    protected function getComputopPayment(QuoteTransfer $quoteTransfer)
45
    {
46
        return $quoteTransfer->getPayment()->getComputopSofort();
47
    }
48
}
49