Completed
Push — feature/eco-3656/eco-3658-enab... ( ab05e4...16d9cc )
by
unknown
06:10
created

fillQuoteWithDummyData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 12
rs 10
c 0
b 0
f 0
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\Handler\ExpressCheckout;
9
10
use Generated\Shared\Transfer\AddressTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\AddressTransfer 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\ComputopApiPayPalExpressPrepareResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...PrepareResponseTransfer 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\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...
13
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...
14
use Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface;
15
use SprykerEco\Service\ComputopApi\ComputopApiServiceInterface;
16
use SprykerEco\Yves\Computop\ComputopConfigInterface;
17
use SprykerEco\Yves\Computop\Dependency\Client\ComputopToComputopApiClientInterface;
18
use SprykerEco\Yves\Computop\Dependency\Client\ComputopToQuoteClientInterface;
19
20
class ComputopPayPalExpressPrepareHandler implements ComputopPayPalExpressPrepareHandlerInterface
21
{
22
    /**
23
     * @var \Spryker\Client\Quote\QuoteClientInterface
24
     */
25
    protected $quoteClient;
26
27
    /**
28
     * @var \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface
29
     */
30
    protected $stepEngineFormDataProvider;
31
32
    /**
33
     * @var \SprykerEco\Yves\Computop\Dependency\Client\ComputopToComputopApiClientInterface
34
     */
35
    protected $computopApiClient;
36
37
    /**
38
     * @var \SprykerEco\Service\ComputopApi\ComputopApiServiceInterface
39
     */
40
    protected $computopApiService;
41
42
    /**
43
     * @var \SprykerEco\Yves\Computop\ComputopConfigInterface
44
     */
45
    protected $computopConfig;
46
47
    public function __construct(
48
        ComputopToQuoteClientInterface $quoteClient,
49
        StepEngineFormDataProviderInterface $stepEngineFormDataProvider,
50
        ComputopToComputopApiClientInterface $computopApiClient,
51
        ComputopApiServiceInterface $computopApiService,
52
        ComputopConfigInterface $computopConfig
53
    ) {
54
        $this->quoteClient = $quoteClient;
0 ignored issues
show
Documentation Bug introduced by
It seems like $quoteClient of type SprykerEco\Yves\Computop...pToQuoteClientInterface is incompatible with the declared type Spryker\Client\Quote\QuoteClientInterface of property $quoteClient.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
55
        $this->stepEngineFormDataProvider = $stepEngineFormDataProvider;
56
        $this->computopApiClient = $computopApiClient;
57
        $this->computopApiService = $computopApiService;
58
        $this->computopConfig = $computopConfig;
59
    }
60
61
62
    /**
63
     * @param QuoteTransfer $quoteTransfer
64
     *
65
     * @return \Generated\Shared\Transfer\ComputopApiPayPalExpressPrepareResponseTransfer
66
     */
67
    public function handle(QuoteTransfer $quoteTransfer): ComputopApiPayPalExpressPrepareResponseTransfer
68
    {
69
        $quoteTransfer = $this->fillQuoteWithDummyData($quoteTransfer);
70
        $quoteTransfer = $this->stepEngineFormDataProvider->getData($quoteTransfer);
71
72
        $quoteTransfer = $this->computopApiClient->sendPayPalExpressPrepareRequest($quoteTransfer);
73
74
        $this->quoteClient->setQuote($quoteTransfer);
75
76
        return $quoteTransfer->getPayment()->getComputopPayPalExpress()->getPayPalExpressPrepareResponse();
77
    }
78
79
    /**
80
     * @param QuoteTransfer $quoteTransfer
81
     *
82
     * @return QuoteTransfer
83
     */
84
    protected function fillQuoteWithDummyData(QuoteTransfer $quoteTransfer): QuoteTransfer
85
    {
86
        //        Customer kostyl
87
        $customer = new CustomerTransfer();
88
        $customer->setCustomerReference('123');
89
        $customer->setIsGuest(true);
90
        $quoteTransfer->setCustomer($customer);
91
92
        //zip kostyl
93
        $address = new AddressTransfer();
94
        $address->setZipCode(65000);
95
        $quoteTransfer->setShippingAddress($address);
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Generated\Shared\Transfer\QuoteTransfer. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
96
    }
97
}
98