Passed
Push — feature/eco-3656/eco-3658-enab... ( 202423...b8179e )
by
unknown
06:13
created

mapAddressFromComputopPayPalExpressInitResponseToQuote()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 29
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 29
rs 9.7
c 0
b 0
f 0
cc 3
nc 4
nop 2
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Yves\Computop\Mapper\Init\PrePlace;
9
10
use Generated\Shared\Transfer\AddressTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\AddressTransfer 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\ComputopPayPalExpressInitResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...essInitResponseTransfer 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 Generated\Shared\Transfer\CountryTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\CountryTransfer 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...
13
use Generated\Shared\Transfer\CustomerTransfer;
0 ignored issues
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...
14
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...
15
use Spryker\Shared\Kernel\Transfer\AbstractTransfer;
16
17
class PayPalExpressToQuoteMapper implements PayPalExpressToQuoteMapperInterface
18
{
19
    /**
20
     * @param \Generated\Shared\Transfer\ComputopPayPalExpressInitResponseTransfer $computopPayPalExpressInitResponseTransfer
21
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
22
     *
23
     * @return \Generated\Shared\Transfer\QuoteTransfer
24
     */
25
    public function mapAddressFromComputopPayPalExpressInitResponseToQuote(
26
        ComputopPayPalExpressInitResponseTransfer $computopPayPalExpressInitResponseTransfer,
27
        QuoteTransfer $quoteTransfer
28
    ): QuoteTransfer
29
    {
30
        $countryTransfer = new CountryTransfer();
31
        $countryTransfer->setIso2Code($computopPayPalExpressInitResponseTransfer->getAddressCountryCode());
32
33
        $shippingAddressTransfer = new AddressTransfer();
34
        $shippingAddressTransfer->fromArray($computopPayPalExpressInitResponseTransfer->toArray(), true);
35
        $shippingAddressTransfer->setAddress1($computopPayPalExpressInitResponseTransfer->getAddressStreet());
36
        $shippingAddressTransfer->setAddress2($computopPayPalExpressInitResponseTransfer->getAddressStreet2());
37
        $shippingAddressTransfer->setCity($computopPayPalExpressInitResponseTransfer->getAddressCity());
38
        $shippingAddressTransfer->setState($computopPayPalExpressInitResponseTransfer->getAddressState());
39
        $shippingAddressTransfer->setZipCode($computopPayPalExpressInitResponseTransfer->getAddressZip());
40
        $shippingAddressTransfer->setIso2Code($computopPayPalExpressInitResponseTransfer->getAddressCountryCode());
41
        $shippingAddressTransfer->setCountry($countryTransfer);
42
43
        foreach ($quoteTransfer->getItems() as $itemTransfer) {
44
            $itemTransfer->getShipment()->setShippingAddress($shippingAddressTransfer);
45
        }
46
47
        foreach ($quoteTransfer->getExpenses() as $expenseTransfer) {
48
            $expenseTransfer->getShipment()->setShippingAddress($shippingAddressTransfer);
49
        }
50
51
        $quoteTransfer->setShippingAddress($shippingAddressTransfer);
52
53
        return $quoteTransfer;
54
    }
55
56
    /**
57
     * @param \Generated\Shared\Transfer\ComputopPayPalExpressInitResponseTransfer $computopPayPalExpressInitResponseTransfer
58
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
59
     *
60
     * @return \Generated\Shared\Transfer\QuoteTransfer
61
     */
62
    public function mapBillingAddressFromComputopPayPalExpressInitResponseToQuote(
63
        ComputopPayPalExpressInitResponseTransfer $computopPayPalExpressInitResponseTransfer,
64
        QuoteTransfer $quoteTransfer
65
    ): QuoteTransfer
66
    {
67
        $countryTransfer = new CountryTransfer();
68
        $countryTransfer->setIso2Code($computopPayPalExpressInitResponseTransfer->getAddressCountryCode());
69
70
        $billingAddressTransfer = new AddressTransfer();
71
        $billingAddressTransfer->fromArray($computopPayPalExpressInitResponseTransfer->toArray(), true);
72
        $billingAddressTransfer->setAddress1($computopPayPalExpressInitResponseTransfer->getBillingAddressStreet());
73
        $billingAddressTransfer->setAddress2($computopPayPalExpressInitResponseTransfer->getBillingAddressStreet2());
74
        $billingAddressTransfer->setZipCode($computopPayPalExpressInitResponseTransfer->getBillingAddressZip());
75
        $billingAddressTransfer->setCity($computopPayPalExpressInitResponseTransfer->getBillingAddressCity());
76
        $billingAddressTransfer->setState($computopPayPalExpressInitResponseTransfer->getBillingAddressState());
77
        $billingAddressTransfer->setIso2Code($computopPayPalExpressInitResponseTransfer->getBillingAddressCountryCode());
78
        $billingAddressTransfer->setCountry($countryTransfer);
79
        $billingAddressTransfer->setFirstName($computopPayPalExpressInitResponseTransfer->getBillingName());
80
        $billingAddressTransfer->setLastName($computopPayPalExpressInitResponseTransfer->getLastName());
81
82
        $quoteTransfer->setBillingAddress($billingAddressTransfer);
83
84
        return $quoteTransfer;
85
    }
86
87
    /**
88
     * @param \Generated\Shared\Transfer\ComputopPayPalExpressInitResponseTransfer $computopPayPalExpressInitResponseTransfer
89
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
90
     *
91
     * @return \Generated\Shared\Transfer\QuoteTransfer
92
     */
93
    public function mapCustomerFromComputopPayPalExpressInitResponseToQuote(
94
        ComputopPayPalExpressInitResponseTransfer $computopPayPalExpressInitResponseTransfer,
95
        QuoteTransfer $quoteTransfer
96
    ): QuoteTransfer
97
    {
98
        $customerTransfer = new CustomerTransfer();
99
        $customerTransfer->fromArray($computopPayPalExpressInitResponseTransfer->toArray(), true);
100
        $customerTransfer->setIsGuest(true);
101
        $quoteTransfer->setAcceptTermsAndConditions(true);
102
        $quoteTransfer->setCustomer($customerTransfer);
103
104
        return $quoteTransfer;
105
    }
106
}
107