Passed
Pull Request — master (#44)
by Michael
12:21 queued 08:36
created

PayPalExpressFormDataProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 14
dl 0
loc 38
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getComputopPayment() 0 3 1
A getData() 0 21 4
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\CustomerTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\CustomerTransfer 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 PayPalExpressFormDataProvider 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): QuoteTransfer
23
    {
24
        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

24
        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...
25
            $quoteTransfer->setPayment(new 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(new 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
            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 type-hinted return Generated\Shared\Transfer\QuoteTransfer.
Loading history...
30
        }
31
32
        $paymentTransfer = $quoteTransfer->getPayment();
33
        /** @var \Generated\Shared\Transfer\ComputopPayPalExpressPaymentTransfer $computopPayPalExpressPaymentTransfer */
34
        $computopPayPalExpressPaymentTransfer = $this->mapper->createComputopPaymentTransfer($quoteTransfer);
35
        $paymentTransfer->setComputopPayPalExpress($computopPayPalExpressPaymentTransfer);
36
        $paymentTransfer->setAmount($quoteTransfer->getTotals()->getGrandTotal());
0 ignored issues
show
Bug introduced by
The method getTotals() 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

36
        $paymentTransfer->setAmount($quoteTransfer->/** @scrutinizer ignore-call */ getTotals()->getGrandTotal());

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...
37
        $quoteTransfer->setPayment($paymentTransfer);
38
        if ($quoteTransfer->getCustomer() === null) {
0 ignored issues
show
Bug introduced by
The method getCustomer() 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

38
        if ($quoteTransfer->/** @scrutinizer ignore-call */ getCustomer() === 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...
39
            $quoteTransfer->setCustomer(new CustomerTransfer());
0 ignored issues
show
Bug introduced by
The method setCustomer() 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

39
            $quoteTransfer->/** @scrutinizer ignore-call */ 
40
                            setCustomer(new CustomerTransfer());

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
        }
41
42
        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 type-hinted return Generated\Shared\Transfer\QuoteTransfer.
Loading history...
43
    }
44
45
    /**
46
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
47
     *
48
     * @return \Spryker\Shared\Kernel\Transfer\TransferInterface
49
     */
50
    protected function getComputopPayment(QuoteTransfer $quoteTransfer)
51
    {
52
        return $quoteTransfer->getPayment()->getComputopPayPalExpress();
53
    }
54
}
55