Completed
Push — master ( 56a686...736967 )
by Oleksandr
15s queued 11s
created

HeidelpayEasycreditStep::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Yves\Heidelpay\CheckoutPage\Process\Steps;
9
10
use Spryker\Shared\Kernel\Transfer\AbstractTransfer;
11
use Spryker\Yves\StepEngine\Dependency\Step\StepWithExternalRedirectInterface;
12
use SprykerEco\Shared\Heidelpay\HeidelpayConfig;
13
use SprykerShop\Yves\CheckoutPage\Process\Steps\AbstractBaseStep;
14
use Symfony\Component\HttpFoundation\Request;
15
16
class HeidelpayEasycreditStep extends AbstractBaseStep implements StepWithExternalRedirectInterface
17
{
18
    /**
19
     * @var string
20
     */
21
    protected $externalRedirectUrl;
22
23
    /**
24
     * @param \Spryker\Shared\Kernel\Transfer\AbstractTransfer $quoteTransfer
25
     *
26
     * @return bool
27
     */
28
    public function requireInput(AbstractTransfer $quoteTransfer)
29
    {
30
        return false;
31
    }
32
33
    /**
34
     * @param \Symfony\Component\HttpFoundation\Request $request
35
     * @param \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...
36
     *
37
     * @return \Generated\Shared\Transfer\QuoteTransfer|\Spryker\Shared\Kernel\Transfer\AbstractTransfer
38
     */
39
    public function execute(Request $request, AbstractTransfer $quoteTransfer)
40
    {
41
        if ($this->isEasyCreditPaymentMethod($quoteTransfer) === false) {
42
            return $quoteTransfer;
1 ignored issue
show
Bug Best Practice introduced by
The expression return $quoteTransfer returns the type Spryker\Shared\Kernel\Transfer\AbstractTransfer which is incompatible with the return type mandated by Spryker\Yves\StepEngine\...tepInterface::execute() of Generated\Shared\Transfer\QuoteTransfer.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
43
        }
44
45
        $this->externalRedirectUrl = $quoteTransfer->getHeidelpayPayment()->getExternalRedirectUrl();
0 ignored issues
show
Bug introduced by
The method getHeidelpayPayment() 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

45
        $this->externalRedirectUrl = $quoteTransfer->/** @scrutinizer ignore-call */ getHeidelpayPayment()->getExternalRedirectUrl();

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;
1 ignored issue
show
Bug Best Practice introduced by
The expression return $quoteTransfer returns the type Spryker\Shared\Kernel\Transfer\AbstractTransfer which is incompatible with the return type mandated by Spryker\Yves\StepEngine\...tepInterface::execute() of Generated\Shared\Transfer\QuoteTransfer.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getExternalRedirectUrl()
54
    {
55
        return $this->externalRedirectUrl;
56
    }
57
58
    /**
59
     * @param \Spryker\Shared\Kernel\Transfer\AbstractTransfer|\Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
60
     *
61
     * @return bool
62
     */
63
    public function postCondition(AbstractTransfer $quoteTransfer)
64
    {
65
        return true;
66
    }
67
68
    /**
69
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
70
     *
71
     * @return bool
72
     */
73
    protected function isEasyCreditPaymentMethod(AbstractTransfer $quoteTransfer): bool
74
    {
75
        $result = ($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

75
        $result = ($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...
76
            && $quoteTransfer->getPayment()->getPaymentSelection() === HeidelpayConfig::PAYMENT_METHOD_EASY_CREDIT);
77
78
        return $result;
79
    }
80
}
81