Completed
Push — feature/paypal-express ( 45c1ed...8563e1 )
by Oleksandr
22:44 queued 22:43
created

PaypalResponseProcessor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 53
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A processSuccessResponse() 0 6 1
A updateQuoteDependOnResponse() 0 11 1
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\Braintree\Model\Processor;
9
10
use Generated\Shared\Transfer\PaypalExpressSuccessResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...SuccessResponseTransfer 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 SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToQuoteClientInterface;
13
use SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapperInterface;
14
15
class PaypalResponseProcessor implements PaypalResponseProcessorInterface
16
{
17
    /**
18
     * @var \SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapperInterface
19
     */
20
    protected $paypalResponseMapper;
21
22
    /**
23
     * @var \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToQuoteClientInterface
24
     */
25
    protected $quoteClient;
26
27
    /**
28
     * @param \SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapperInterface $paypalResponseMapper
29
     * @param \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToQuoteClientInterface $quoteClient
30
     */
31
    public function __construct(
32
        PaypalResponseMapperInterface $paypalResponseMapper,
33
        BraintreeToQuoteClientInterface $quoteClient
34
    ) {
35
        $this->paypalResponseMapper = $paypalResponseMapper;
36
        $this->quoteClient = $quoteClient;
37
    }
38
39
    /**
40
     * @param array $payload
41
     *
42
     * @return \Generated\Shared\Transfer\QuoteTransfer
43
     */
44
    public function processSuccessResponse(array $payload): QuoteTransfer
45
    {
46
        $paypalExpressSuccessResponseTransfer = $this->paypalResponseMapper->mapSuccessResponseToPaypalExpressSuccessResponseTransfer($payload);
47
        $quoteTransfer = $this->updateQuoteDependOnResponse($paypalExpressSuccessResponseTransfer);
48
49
        return $quoteTransfer;
50
    }
51
52
    /**
53
     * @param \Generated\Shared\Transfer\PaypalExpressSuccessResponseTransfer $paypalExpressSuccessResponseTransfer
54
     *
55
     * @return \Generated\Shared\Transfer\QuoteTransfer
56
     */
57
    protected function updateQuoteDependOnResponse(PaypalExpressSuccessResponseTransfer $paypalExpressSuccessResponseTransfer): QuoteTransfer
58
    {
59
        $quoteTransfer = $this->quoteClient->getQuote();
60
        $quoteTransfer = $this->paypalResponseMapper->mapPaypalExpressSuccessResponseTransferToQuoteTransfer(
61
            $paypalExpressSuccessResponseTransfer,
62
            $quoteTransfer
63
        );
64
65
        $this->quoteClient->setQuote($quoteTransfer);
66
67
        return $quoteTransfer;
68
    }
69
}
70