Completed
Push — feature/ECO-1185-eco-ci ( 4da4ac...5d4add )
by Andrey
13:41 queued 10:25
created

GuestCustomerDataQuoteUpdater::update()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
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 GuestCustomerDataQuoteUpdater 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
        if ($quoteTransfer->getCustomer() !== null) {
23
            return $quoteTransfer;
24
        }
25
26
        $amazonCallTransfer = $this->convertQuoteTransferToAmazonPayTransfer($quoteTransfer);
27
28
        $responseTransfer = $this->executionAdapter->call($amazonCallTransfer);
29
30
        $this->updateCustomer($quoteTransfer, $responseTransfer->getCustomer());
31
32
        return $quoteTransfer;
33
    }
34
35
    /**
36
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
37
     * @param \Generated\Shared\Transfer\CustomerTransfer $customer
38
     *
39
     * @return void
40
     */
41
    protected function updateCustomer(QuoteTransfer $quoteTransfer, CustomerTransfer $customer)
42
    {
43
        if (!$quoteTransfer->getCustomer()) {
44
            $quoteTransfer->setCustomer(new CustomerTransfer());
45
        }
46
47
        $quoteTransfer->getCustomer()->fromArray($customer->modifiedToArray());
48
49
        if ($quoteTransfer->getCustomer()->getIdCustomer()) {
50
            $quoteTransfer->getCustomer()->setIsGuest(false);
51
        }
52
    }
53
}
54