Completed
Push — master ( e62f85...378d8f )
by Cesar
15s queued 11s
created

User::getDni()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Pagantis\OrdersApiClient\Model\Order;
4
5
use Pagantis\OrdersApiClient\Model\AbstractModel;
6
use Pagantis\OrdersApiClient\Model\Order\User\Address;
7
use Pagantis\OrdersApiClient\Model\Order\User\OrderHistory;
8
9
/**
10
 * Class User
11
 * @package Pagantis\OrdersApiClient\Model\Order
12
 */
13
class User extends AbstractModel
14
{
15
    /**
16
     * @var Address $address User address stored in merchant
17
     */
18
    protected $address;
19
20
    /**
21
     * @var Address $billingAddress Billing address for the order
22
     */
23
    protected $billingAddress;
24
25
    /**
26
     * @var string $dateOfBirth 'YYYY-MM-DD'
27
     */
28
    protected $dateOfBirth;
29
30
    /**
31
     * @var string $dni ID of the user
32
     */
33
    protected $dni;
34
35
    /**
36
     * @var string $email User email.
37
     */
38
    protected $email;
39
40
    /**
41
     * @var string $fixPhone Fix Phone of the user
42
     */
43
    protected $fixPhone;
44
45
    /**
46
     * @var string $fullName Full name of the user including 2 surnames.
47
     */
48
    protected $fullName;
49
50
    /**
51
     * @var string $mobilePhone Mobile phone of the user
52
     */
53
    protected $mobilePhone;
54
55
    /**
56
     * @var string $taxId User Tax Id.
57
     */
58
    protected $taxId;
59
60
    /**
61
     * @var string $nationalId User National Id.
62
     */
63
    protected $nationalId;
64
65
    /**
66
     * @var OrderHistory[] $orderHistory Array of previous orders
67
     */
68
    protected $orderHistory;
69
70
    /**
71
     * @var Address $shippingAddress Shipping address of the order.
72
     */
73
    protected $shippingAddress;
74
75
    /**
76
     * Not adding getters nor setters
77
     *
78
     * @deprecated
79
     */
80
    protected $truncated = false;
81
82
    /**
83
     * Configuration constructor.
84
     */
85
    public function __construct()
86
    {
87
        $this->address = new Address();
88
        $this->billingAddress = new Address();
89
        $this->shippingAddress = new Address();
90
        $this->orderHistory = array();
91
    }
92
93
    /**
94
     * @return Address
95
     */
96
    public function getAddress()
97
    {
98
        return $this->address;
99
    }
100
101
    /**
102
     * @param Address $address
103
     *
104
     * @return User
105
     */
106
    public function setAddress(Address $address)
107
    {
108
        $this->address = $address;
109
110
        return $this;
111
    }
112
113
    /**
114
     * @return Address
115
     */
116
    public function getBillingAddress()
117
    {
118
        return $this->billingAddress;
119
    }
120
121
    /**
122
     * @param Address $billingAddress
123
     *
124
     * @return User
125
     */
126
    public function setBillingAddress(Address $billingAddress)
127
    {
128
        $this->billingAddress = $billingAddress;
129
130
        return $this;
131
    }
132
133
    /**
134
     * @return string
135
     */
136
    public function getDateOfBirth()
137
    {
138
        return $this->dateOfBirth;
139
    }
140
141
    /**
142
     * @param $dateOfBirth
143
     *
144
     * @return $this
145
     */
146
    public function setDateOfBirth($dateOfBirth)
147
    {
148
        $this->dateOfBirth = $this->checkDateFormat($dateOfBirth);
149
150
        return $this;
151
    }
152
153
    /**
154
     * @return string
155
     */
156
    public function getDni()
157
    {
158
        return $this->dni;
159
    }
160
161
    /**
162
     * @param $dni
163
     *
164
     * @return $this
165
     */
166
    public function setDni($dni)
167
    {
168
        $this->dni = $dni;
169
170
        return $this;
171
    }
172
173
    /**
174
     * @return string
175
     */
176
    public function getEmail()
177
    {
178
        return $this->email;
179
    }
180
181
    /**
182
     * @param $email
183
     *
184
     * @return $this
185
     */
186
    public function setEmail($email)
187
    {
188
        $this->email = $email;
189
190
        return $this;
191
    }
192
193
    /**
194
     * @return string
195
     */
196
    public function getFixPhone()
197
    {
198
        return $this->fixPhone;
199
    }
200
201
    /**
202
     * @param string $fixPhone
203
     *
204
     * @return User
205
     */
206
    public function setFixPhone($fixPhone)
207
    {
208
        $this->fixPhone = $fixPhone;
209
210
        return $this;
211
    }
212
213
    /**
214
     * @return string
215
     */
216
    public function getFullName()
217
    {
218
        return $this->fullName;
219
    }
220
221
    /**
222
     * @param $fullName
223
     *
224
     * @return $this
225
     */
226
    public function setFullName($fullName)
227
    {
228
        $this->fullName = $fullName;
229
230
        return $this;
231
    }
232
233
    /**
234
     * @return string
235
     */
236
    public function getMobilePhone()
237
    {
238
        return $this->mobilePhone;
239
    }
240
241
    /**
242
     * @param string $mobilePhone
243
     *
244
     * @return User
245
     */
246
    public function setMobilePhone($mobilePhone)
247
    {
248
        $this->mobilePhone = $mobilePhone;
249
250
        return $this;
251
    }
252
253
    /**
254
     * @return string
255
     */
256
    public function getTaxId()
257
    {
258
        return $this->taxId;
259
    }
260
261
    /**
262
     * @param string $taxId
263
     *
264
     * @return User
265
     */
266
    public function setTaxId($taxId)
267
    {
268
        $this->taxId = $taxId;
269
270
        return $this;
271
    }
272
273
    /**
274
     * @return string
275
     */
276
    public function getNationalId()
277
    {
278
        return $this->nationalId;
279
    }
280
281
    /**
282
     * @param string $nationalId
283
     *
284
     * @return User
285
     */
286
    public function setNationalId($nationalId)
287
    {
288
        $this->nationalId = $nationalId;
289
290
        return $this;
291
    }
292
293
    /**
294
     * @return array
295
     */
296
    public function getOrderHistory()
297
    {
298
        return $this->orderHistory;
299
    }
300
301
    /**
302
     * @param OrderHistory $orderHistory
303
     *
304
     * @return $this
305
     */
306
    public function addOrderHistory(OrderHistory $orderHistory)
307
    {
308
        $this->orderHistory[] = $orderHistory;
309
310
        return $this;
311
    }
312
313
    /**
314
     * @return Address
315
     */
316
    public function getShippingAddress()
317
    {
318
        return $this->shippingAddress;
319
    }
320
321
    /**
322
     * @param Address $shippingAddress
323
     *
324
     * @return User
325
     */
326
    public function setShippingAddress(Address $shippingAddress)
327
    {
328
        $this->shippingAddress = $shippingAddress;
329
330
        return $this;
331
    }
332
333
    /**
334
     * Overwrite import to fill ordersHistory correctly
335
     *
336
     * @param \stdClass $object
337
     * @throws \Exception
338
     *
339
     */
340
    public function import($object)
341
    {
342
        parent::import($object);
343
        $properties = get_object_vars($object);
344
        foreach ($properties as $key => $value) {
345
            if (is_array($value) && $key == 'order_history') {
346
                $this->orderHistory = array();
347
                foreach ($value as $orderHistory) {
348
                    $orderHistoryObject = new OrderHistory();
349
                    $orderHistoryObject->import($orderHistory);
350
                    $this->addOrderHistory($orderHistoryObject);
351
                }
352
            }
353
        }
354
    }
355
}
356