Passed
Pull Request — feature/eco-3656/dev-paypal-ex... (#40)
by
unknown
11:25 queued 06:05
created

ComputopPayPalExpressPrepareHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
wmc 2
eloc 15
c 1
b 1
f 1
dl 0
loc 61
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A handle() 0 8 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\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...
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\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface;
13
use SprykerEco\Service\ComputopApi\ComputopApiServiceInterface;
14
use SprykerEco\Yves\Computop\ComputopConfigInterface;
15
use SprykerEco\Yves\Computop\Dependency\Client\ComputopToComputopApiClientInterface;
16
use SprykerEco\Yves\Computop\Dependency\Client\ComputopToQuoteClientInterface;
17
18
class ComputopPayPalExpressPrepareHandler implements ComputopPayPalExpressPrepareHandlerInterface
19
{
20
    /**
21
     * @var \SprykerEco\Yves\Computop\Dependency\Client\ComputopToQuoteClientInterface
22
     */
23
    protected $quoteClient;
24
25
    /**
26
     * @var \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface
27
     */
28
    protected $stepEngineFormDataProvider;
29
30
    /**
31
     * @var \SprykerEco\Yves\Computop\Dependency\Client\ComputopToComputopApiClientInterface
32
     */
33
    protected $computopApiClient;
34
35
    /**
36
     * @var \SprykerEco\Service\ComputopApi\ComputopApiServiceInterface
37
     */
38
    protected $computopApiService;
39
40
    /**
41
     * @var \SprykerEco\Yves\Computop\ComputopConfigInterface
42
     */
43
    protected $computopConfig;
44
45
    /**
46
     * @param \SprykerEco\Yves\Computop\Dependency\Client\ComputopToQuoteClientInterface $quoteClient
47
     * @param \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface $stepEngineFormDataProvider
48
     * @param \SprykerEco\Yves\Computop\Dependency\Client\ComputopToComputopApiClientInterface $computopApiClient
49
     * @param \SprykerEco\Service\ComputopApi\ComputopApiServiceInterface $computopApiService
50
     * @param \SprykerEco\Yves\Computop\ComputopConfigInterface $computopConfig
51
     */
52
    public function __construct(
53
        ComputopToQuoteClientInterface $quoteClient,
54
        StepEngineFormDataProviderInterface $stepEngineFormDataProvider,
55
        ComputopToComputopApiClientInterface $computopApiClient,
56
        ComputopApiServiceInterface $computopApiService,
57
        ComputopConfigInterface $computopConfig
58
    ) {
59
        $this->quoteClient = $quoteClient;
60
        $this->stepEngineFormDataProvider = $stepEngineFormDataProvider;
61
        $this->computopApiClient = $computopApiClient;
62
        $this->computopApiService = $computopApiService;
63
        $this->computopConfig = $computopConfig;
64
    }
65
66
    /**
67
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
68
     *
69
     * @return \Generated\Shared\Transfer\ComputopApiPayPalExpressPrepareResponseTransfer
70
     */
71
    public function handle(QuoteTransfer $quoteTransfer): ComputopApiPayPalExpressPrepareResponseTransfer
72
    {
73
        $quoteTransfer = $this->stepEngineFormDataProvider->getData($quoteTransfer);
74
        $quoteTransfer = $this->computopApiClient->sendPayPalExpressPrepareRequest($quoteTransfer);
75
76
        $this->quoteClient->setQuote($quoteTransfer);
77
78
        return $quoteTransfer->getPayment()->getComputopPayPalExpress()->getPayPalExpressPrepareResponse();
79
    }
80
}
81