Passed
Push — feature/ECO-808-scrutinizer ( bde35b...0b4fa5 )
by Andrey
02:56
created

CustomerDataQuoteUpdater::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 6
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;
11
use Generated\Shared\Transfer\QuoteTransfer;
12
13
class CustomerDataQuoteUpdater extends QuoteUpdaterAbstract
14
{
15
16
    /**
17
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
18
     *
19
     * @return \Generated\Shared\Transfer\QuoteTransfer
20
     */
21
    public function update(QuoteTransfer $quoteTransfer)
22
    {
23
        $amazonCallTransfer = $this->convertQuoteTransferToAmazonPayTransfer($quoteTransfer);
24
        $customer = $this->executionAdapter->call($amazonCallTransfer);
25
26
        $this->updateCustomer($quoteTransfer, $customer);
0 ignored issues
show
Bug introduced by
$customer of type Generated\Shared\Transfe...azonpayResponseTransfer is incompatible with the type Generated\Shared\Transfer\CustomerTransfer expected by parameter $customer of SprykerEco\Zed\Amazonpay...dater::updateCustomer(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
        $this->updateCustomer($quoteTransfer, /** @scrutinizer ignore-type */ $customer);
Loading history...
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($customer);
41
42
            return;
43
        }
44
45
        $quoteTransfer->getCustomer()->fromArray($customer->modifiedToArray());
46
47
        if ($quoteTransfer->getCustomer()->getIdCustomer()) {
48
            $quoteTransfer->getCustomer()->setIsGuest(false);
49
        }
50
    }
51
52
}
53