Passed
Push — feature/paypal-express ( 956c37...c5cd7f )
by Volodymyr
05:02
created

updateQuoteDependOnResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SprykerEco\Yves\Braintree\Model\Processor;
4
5
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...
6
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...
7
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToQuoteClientInterface;
8
use SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapperInterface;
9
10
class PaypalResponseProcessor implements PaypalResponseProcessorInterface
11
{
12
    /**
13
     * @var PaypalResponseMapperInterface
14
     */
15
    protected $paypalResponseMapper;
16
17
    /**
18
     * @var BraintreeToQuoteClientInterface
19
     */
20
    protected $quoteClient;
21
22
    /**
23
     * @param PaypalResponseMapperInterface $paypalResponseMapper
24
     * @param BraintreeToQuoteClientInterface $quoteClient
25
     */
26
    public function __construct(
27
        PaypalResponseMapperInterface $paypalResponseMapper,
28
        BraintreeToQuoteClientInterface $quoteClient
29
    ) {
30
        $this->paypalResponseMapper = $paypalResponseMapper;
31
        $this->quoteClient = $quoteClient;
32
    }
33
34
    /**
35
     * @param array $payload
36
     *
37
     * @return QuoteTransfer
38
     */
39
    public function processSuccessResponse(array $payload): QuoteTransfer
40
    {
41
        $paypalExpressSuccessResponseTransfer = $this->paypalResponseMapper->mapSuccessResponseToPaypalExpressSuccessResponseTransfer($payload);
42
        $quoteTransfer = $this->updateQuoteDependOnResponse($paypalExpressSuccessResponseTransfer);
43
44
        return $quoteTransfer;
45
    }
46
47
    /**
48
     * @param PaypalExpressSuccessResponseTransfer $paypalExpressSuccessResponseTransfer
49
     *
50
     * @return QuoteTransfer
51
     */
52
    protected function updateQuoteDependOnResponse(PaypalExpressSuccessResponseTransfer $paypalExpressSuccessResponseTransfer): QuoteTransfer
53
    {
54
        $quoteTransfer = $this->quoteClient->getQuote();
55
        $quoteTransfer = $this->paypalResponseMapper->mapPaypalExpressSuccessResponseTransferToQuoteTransfer(
56
            $paypalExpressSuccessResponseTransfer,
57
            $quoteTransfer
58
        );
59
60
        $this->quoteClient->setQuote($quoteTransfer);
61
62
        return $quoteTransfer;
63
    }
64
}