Issues (139)

Gateway/Data/Order/OrderAdapter.php (2 issues)

1
<?php
2
/**
3
 * Copyright © Getnet. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See LICENSE for license details.
7
 */
8
9
namespace Getnet\PaymentMagento\Gateway\Data\Order;
10
11
use Magento\Payment\Gateway\Data\AddressAdapterInterface;
12
use Magento\Payment\Gateway\Data\OrderAdapterInterface;
13
use Magento\Sales\Model\Order;
14
15
/**
16
 * Class OrderAdapter - Adds necessary information to the order.
17
 */
18
class OrderAdapter implements OrderAdapterInterface
19
{
20
    /**
21
     * @var Order
22
     */
23
    private $order;
24
25
    /**
26
     * @var AddressAdapterFactory
0 ignored issues
show
The type Getnet\PaymentMagento\Ga...r\AddressAdapterFactory 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...
27
     */
28
    private $addAdapterFactory;
29
30
    /**
31
     * @param Order                 $order
32
     * @param AddressAdapterFactory $addAdapterFactory
33
     */
34
    public function __construct(
35
        Order $order,
36
        AddressAdapterFactory $addAdapterFactory
37
    ) {
38
        $this->order = $order;
39
        $this->addAdapterFactory = $addAdapterFactory;
40
    }
41
42
    /**
43
     * Returns currency code.
44
     *
45
     * @return string
46
     */
47
    public function getCurrencyCode()
48
    {
49
        return $this->order->getBaseCurrencyCode();
50
    }
51
52
    /**
53
     * Returns order increment id.
54
     *
55
     * @return string
56
     */
57
    public function getOrderIncrementId()
58
    {
59
        return $this->order->getIncrementId();
60
    }
61
62
    /**
63
     * Returns customer ID.
64
     *
65
     * @return int|null
66
     */
67
    public function getCustomerId()
68
    {
69
        return $this->order->getCustomerId();
70
    }
71
72
    /**
73
     * Returns billing address.
74
     *
75
     * @return AddressAdapterInterface|null
76
     */
77
    public function getBillingAddress()
78
    {
79
        if ($this->order->getBillingAddress()) {
80
            return $this->addAdapterFactory->create(
81
                ['address' => $this->order->getBillingAddress()]
82
            );
83
        }
84
85
        return null;
86
    }
87
88
    /**
89
     * Returns shipping address.
90
     *
91
     * @return AddressAdapterInterface|null
92
     */
93
    public function getShippingAddress()
94
    {
95
        if ($this->order->getShippingAddress()) {
96
            return $this->addAdapterFactory->create(
97
                ['address' => $this->order->getShippingAddress()]
98
            );
99
        }
100
101
        return null;
102
    }
103
104
    /**
105
     * Returns order store id.
106
     *
107
     * @return int
108
     */
109
    public function getStoreId()
110
    {
111
        return $this->order->getStoreId();
112
    }
113
114
    /**
115
     * Returns order id.
116
     *
117
     * @return int
118
     */
119
    public function getId()
120
    {
121
        return $this->order->getEntityId();
122
    }
123
124
    /**
125
     * Returns order grand total amount.
126
     *
127
     * @return float|null
128
     */
129
    public function getGrandTotalAmount()
130
    {
131
        return $this->order->getBaseGrandTotal();
132
    }
133
134
    /**
135
     * Returns list of line items in the cart.
136
     *
137
     * @return \Magento\Sales\Api\Data\OrderItemInterface[]
138
     */
139
    public function getItems()
140
    {
141
        return $this->order->getItems();
142
    }
143
144
    /**
145
     * Gets the remote IP address for the order.
146
     *
147
     * @return string|null Remote IP address.
148
     */
149
    public function getRemoteIp()
150
    {
151
        return $this->order->getRemoteIp();
152
    }
153
154
    /**
155
     * Gets the Dob for the customer.
156
     *
157
     * @return string.
0 ignored issues
show
Documentation Bug introduced by
The doc comment string. at position 0 could not be parsed: Unknown type name 'string.' at position 0 in string..
Loading history...
158
     */
159
    public function getCustomerDob()
160
    {
161
        return $this->order->getCustomerDob();
162
    }
163
164
    /**
165
     * Gets the Tax/Vat for the customer.
166
     *
167
     * @return string|null Tax/Vat.
168
     */
169
    public function getCustomerTaxvat()
170
    {
171
        return $this->order->getCustomerTaxvat();
172
    }
173
174
    /**
175
     * Returns order sub total amount.
176
     *
177
     * @return float|null
178
     */
179
    public function getSubTotal()
180
    {
181
        return $this->order->getSubTotal();
182
    }
183
184
    /**
185
     * Returns order shipping total amount.
186
     *
187
     * @return float|null
188
     */
189
    public function getShippingAmount()
190
    {
191
        return $this->order->getShippingAmount();
192
    }
193
194
    /**
195
     * Returns order discount total amount.
196
     *
197
     * @return float|null
198
     */
199
    public function getDiscountAmount()
200
    {
201
        return $this->order->getDiscountAmount();
202
    }
203
204
    /**
205
     * Returns order tax total amount.
206
     *
207
     * @return float|null
208
     */
209
    public function getTaxAmount()
210
    {
211
        return $this->order->getTaxAmount();
212
    }
213
214
    /**
215
     * Returns order quote id.
216
     *
217
     * @return float|null
218
     */
219
    public function getQuoteId()
220
    {
221
        return $this->order->getQuoteId();
222
    }
223
}
224