RiskCheckRequestMapper::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 2
b 0
f 0
nc 1
nop 4
dl 0
loc 10
rs 10
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Zed\ArvatoRss\Business\Api\Mapper;
9
10
use Generated\Shared\Transfer\ArvatoRssRiskCheckRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...iskCheckRequestTransfer 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\BillingCustomerMapperTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...gCustomerMapperTransfer 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\DeliveryCustomerMapperTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...yCustomerMapperTransfer 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\OrderMapperTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\OrderMapperTransfer 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 SprykerEco\Zed\ArvatoRss\Business\Api\Mapper\Aspect\BillingCustomerMapperInterface;
16
use SprykerEco\Zed\ArvatoRss\Business\Api\Mapper\Aspect\DeliveryCustomerMapperInterface;
17
use SprykerEco\Zed\ArvatoRss\Business\Api\Mapper\Aspect\IdentificationMapperInterface;
18
use SprykerEco\Zed\ArvatoRss\Business\Api\Mapper\Aspect\OrderMapperInterface;
19
20
class RiskCheckRequestMapper implements RiskCheckRequestMapperInterface
21
{
22
    /**
23
     * @var \SprykerEco\Zed\ArvatoRss\Business\Api\Mapper\Aspect\IdentificationMapperInterface
24
     */
25
    protected $identificationMapper;
26
27
    /**
28
     * @var \SprykerEco\Zed\ArvatoRss\Business\Api\Mapper\Aspect\BillingCustomerMapperInterface
29
     */
30
    protected $billingCustomerMapper;
31
32
    /**
33
     * @var \SprykerEco\Zed\ArvatoRss\Business\Api\Mapper\Aspect\DeliveryCustomerMapperInterface
34
     */
35
    protected $deliveryCustomerMapper;
36
37
    /**
38
     * @var \SprykerEco\Zed\ArvatoRss\Business\Api\Mapper\Aspect\OrderMapperInterface
39
     */
40
    protected $orderMapper;
41
42
    /**
43
     * @param \SprykerEco\Zed\ArvatoRss\Business\Api\Mapper\Aspect\IdentificationMapperInterface $identificationMapper
44
     * @param \SprykerEco\Zed\ArvatoRss\Business\Api\Mapper\Aspect\BillingCustomerMapperInterface $billingCustomerMapper
45
     * @param \SprykerEco\Zed\ArvatoRss\Business\Api\Mapper\Aspect\DeliveryCustomerMapperInterface $deliveryCustomerMapper
46
     * @param \SprykerEco\Zed\ArvatoRss\Business\Api\Mapper\Aspect\OrderMapperInterface $orderMapper
47
     */
48
    public function __construct(
49
        IdentificationMapperInterface $identificationMapper,
50
        BillingCustomerMapperInterface $billingCustomerMapper,
51
        DeliveryCustomerMapperInterface $deliveryCustomerMapper,
52
        OrderMapperInterface $orderMapper
53
    ) {
54
        $this->identificationMapper = $identificationMapper;
55
        $this->billingCustomerMapper = $billingCustomerMapper;
56
        $this->deliveryCustomerMapper = $deliveryCustomerMapper;
57
        $this->orderMapper = $orderMapper;
58
    }
59
60
    /**
61
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
62
     *
63
     * @return \Generated\Shared\Transfer\ArvatoRssRiskCheckRequestTransfer
64
     */
65
    public function mapQuoteToRequestTranfer(QuoteTransfer $quoteTransfer)
66
    {
67
        $requestTransfer = new ArvatoRssRiskCheckRequestTransfer();
68
69
        $identificationRequestTransfer = $this->identificationMapper->map();
70
        $billingCustomerTransfer = $this->billingCustomerMapper->map(
71
            $this->createBillingCustomerMapperTransfer($quoteTransfer)
72
        );
73
74
        $orderTransfer = $this->orderMapper->map(
75
            $this->createOrderMaperTransfer($quoteTransfer)
76
        );
77
78
        $requestTransfer->setIdentification($identificationRequestTransfer);
79
        $requestTransfer->setBillingCustomer($billingCustomerTransfer);
80
        $requestTransfer->setOrder($orderTransfer);
81
82
        if (!$quoteTransfer->getBillingSameAsShipping()) {
83
            $deliveryCustomerTransfer = $this->deliveryCustomerMapper->map(
84
                $this->createDeliveryCustomerMapperTransfer($quoteTransfer)
85
            );
86
87
            $requestTransfer->setDeliveryCustomer($deliveryCustomerTransfer);
88
        }
89
90
        return $requestTransfer;
91
    }
92
93
    /**
94
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
95
     *
96
     * @return \Generated\Shared\Transfer\BillingCustomerMapperTransfer
97
     */
98
    protected function createBillingCustomerMapperTransfer(QuoteTransfer $quoteTransfer)
99
    {
100
        $transfer = new BillingCustomerMapperTransfer();
101
        $transfer->setEmail($quoteTransfer->getCustomer()->getEmail());
102
        $transfer->setBillingAddress($quoteTransfer->getBillingAddress());
103
        $transfer->setSalutation($quoteTransfer->getCustomer()->getSalutation());
104
105
        return $transfer;
106
    }
107
108
    /**
109
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
110
     *
111
     * @return \Generated\Shared\Transfer\DeliveryCustomerMapperTransfer
112
     */
113
    protected function createDeliveryCustomerMapperTransfer(QuoteTransfer $quoteTransfer)
114
    {
115
        $transfer = new DeliveryCustomerMapperTransfer();
116
        $transfer->setEmail($quoteTransfer->getCustomer()->getEmail());
117
        $transfer->setDeliveryAddress($quoteTransfer->getShippingAddress());
118
        $transfer->setSalutation($quoteTransfer->getCustomer()->getSalutation());
119
120
        return $transfer;
121
    }
122
123
    /**
124
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
125
     *
126
     * @return \Generated\Shared\Transfer\OrderMapperTransfer
127
     */
128
    protected function createOrderMaperTransfer(QuoteTransfer $quoteTransfer)
129
    {
130
        $transfer = new OrderMapperTransfer();
131
        $transfer->setOrderReference($quoteTransfer->getOrderReference());
132
        $transfer->setTotals($quoteTransfer->getTotals());
133
        $transfer->setItems($quoteTransfer->getItems());
134
        $transfer->setCustomerIsGuest($quoteTransfer->getCustomer()->getIsGuest());
135
136
        return $transfer;
137
    }
138
}
139