Passed
Pull Request — dev (#9)
by Andrey
07:30 queued 03:53
created

CustomerDataQuoteUpdater   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 9 1
A updateCustomer() 0 10 3
1
<?php
2
3
/**
4
 * Apache OSL-2
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\AmazonPay\Business\Quote;
9
10
use Generated\Shared\Transfer\CustomerTransfer;
1 ignored issue
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...
11
use Generated\Shared\Transfer\QuoteTransfer;
1 ignored issue
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
13
class CustomerDataQuoteUpdater extends QuoteUpdaterAbstract
14
{
15
    /**
16
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
17
     *
18
     * @return \Generated\Shared\Transfer\QuoteTransfer
19
     */
20
    public function update(QuoteTransfer $quoteTransfer)
21
    {
22
        $amazonCallTransfer = $this->convertQuoteTransferToAmazonPayTransfer($quoteTransfer);
23
24
        $responseTransfer = $this->executionAdapter->call($amazonCallTransfer);
25
26
        $this->updateCustomer($quoteTransfer, $responseTransfer->getCustomer());
27
28
        return $quoteTransfer;
29
    }
30
31
    /**
32
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
33
     * @param \Generated\Shared\Transfer\CustomerTransfer $customer
34
     *
35
     * @return void
36
     */
37
    protected function updateCustomer(QuoteTransfer $quoteTransfer, CustomerTransfer $customer)
38
    {
39
        if (!$quoteTransfer->getCustomer()) {
40
            $quoteTransfer->setCustomer(new CustomerTransfer());
41
        }
42
43
        $quoteTransfer->getCustomer()->fromArray($customer->modifiedToArray());
44
45
        if ($quoteTransfer->getCustomer()->getIdCustomer()) {
46
            $quoteTransfer->getCustomer()->setIsGuest(false);
47
        }
48
    }
49
}
50