Passed
Pull Request — master (#33)
by Aleksey
09:12 queued 01:09
created

ComputopEasyCreditInitStep   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 11
c 1
b 0
f 0
dl 0
loc 53
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 12 3
A requireInput() 0 3 1
A getExternalRedirectUrl() 0 3 1
A postCondition() 0 3 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\CheckoutPage\Process\Steps;
9
10
use Spryker\Shared\Kernel\Transfer\AbstractTransfer;
11
use Spryker\Yves\StepEngine\Dependency\Step\StepWithExternalRedirectInterface;
12
use SprykerEco\Shared\Computop\ComputopConfig;
13
use SprykerShop\Yves\CheckoutPage\Process\Steps\AbstractBaseStep;
14
use Symfony\Component\HttpFoundation\Request;
15
16
class ComputopEasyCreditInitStep extends AbstractBaseStep implements StepWithExternalRedirectInterface
17
{
18
    /**
19
     * @var string
20
     */
21
    protected $redirectUrl = '';
22
23
    /**
24
     * @param \Generated\Shared\Transfer\QuoteTransfer $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...
25
     *
26
     * @return bool
27
     */
28
    public function requireInput(AbstractTransfer $quoteTransfer): bool
29
    {
30
        return false;
31
    }
32
33
    /**
34
     * @param \Symfony\Component\HttpFoundation\Request $request
35
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
36
     *
37
     * @return \Generated\Shared\Transfer\QuoteTransfer
38
     */
39
    public function execute(Request $request, AbstractTransfer $quoteTransfer)
40
    {
41
        if (
42
            !$quoteTransfer->getPayment()
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

42
            !$quoteTransfer->/** @scrutinizer ignore-call */ getPayment()

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...
43
            || $quoteTransfer->getPayment()->getPaymentSelection() !== ComputopConfig::PAYMENT_METHOD_EASY_CREDIT
44
        ) {
45
            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...
46
        }
47
48
        $this->redirectUrl = $quoteTransfer->getPayment()->getComputopEasyCredit()->getUrl();
49
50
        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...
51
    }
52
53
    /**
54
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
55
     *
56
     * @return bool
57
     */
58
    public function postCondition(AbstractTransfer $quoteTransfer): bool
59
    {
60
        return true;
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function getExternalRedirectUrl(): string
67
    {
68
        return $this->redirectUrl;
69
    }
70
}
71