Completed
Push — master ( 74b45c...7e425f )
by Joachim
10:43
created

Order::setModified()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Loevgaard\DandomainFoundation\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
use Loevgaard\DandomainDateTime\DateTimeImmutable;
8
use Loevgaard\DandomainFoundation;
9
use Loevgaard\DandomainFoundation\Entity\Generated\CustomerInterface;
10
use Loevgaard\DandomainFoundation\Entity\Generated\DeliveryInterface;
11
use Loevgaard\DandomainFoundation\Entity\Generated\InvoiceInterface;
12
use Loevgaard\DandomainFoundation\Entity\Generated\OrderInterface;
13
use Loevgaard\DandomainFoundation\Entity\Generated\OrderLineInterface;
14
use Loevgaard\DandomainFoundation\Entity\Generated\OrderTrait;
15
use Loevgaard\DandomainFoundation\Entity\Generated\PaymentMethodInterface;
16
use Loevgaard\DandomainFoundation\Entity\Generated\ShippingMethodInterface;
17
use Loevgaard\DandomainFoundation\Entity\Generated\SiteInterface;
18
use Loevgaard\DandomainFoundation\Entity\Generated\StateInterface;
19
use Money\Money;
20
21
/**
22
 * We use the Money library for amounts, and we use a shared currency, namely the property $currencyCode
23
 *
24
 * @ORM\Entity()
25
 * @ORM\Table(name="ldf_orders")
26
 */
27
class Order extends AbstractEntity implements OrderInterface
28
{
29
    use OrderTrait;
30
31
    /**
32
     * @var int
33
     *
34
     * @ORM\Id
35
     * @ORM\GeneratedValue
36
     * @ORM\Column(type="integer")
37
     **/
38
    protected $id;
39
40
    /**
41
     * This is the order id in Dandomain
42
     *
43
     * @var int
44
     *
45
     * @ORM\Column(type="integer", unique=true)
46
     */
47
    protected $externalId;
48
49
    /**
50
     * @var CustomerInterface|null
51
     *
52
     * @ORM\JoinColumn(onDelete="SET NULL")
53
     * @ORM\ManyToOne(targetEntity="Customer", cascade={"persist", "remove"})
54
     */
55
    protected $customer;
56
57
    /**
58
     * @var DeliveryInterface|null
59
     *
60
     * @ORM\JoinColumn(onDelete="SET NULL")
61
     * @ORM\ManyToOne(targetEntity="Delivery", cascade={"persist", "remove"})
62
     */
63
    protected $delivery;
64
65
    /**
66
     * @var InvoiceInterface|null
67
     *
68
     * @ORM\JoinColumn(onDelete="SET NULL")
69
     * @ORM\ManyToOne(targetEntity="Invoice", cascade={"persist", "remove"})
70
     */
71
    protected $invoice;
72
73
    /**
74
     * @var OrderLine[]|ArrayCollection
75
     *
76
     * @ORM\OneToMany(mappedBy="order", targetEntity="OrderLine", cascade={"persist", "remove"})
77
     */
78
    protected $orderLines;
79
80
    /**
81
     * @var PaymentMethodInterface|null
82
     *
83
     * @ORM\JoinColumn(onDelete="SET NULL")
84
     * @ORM\ManyToOne(targetEntity="PaymentMethod", cascade={"persist", "remove"})
85
     */
86
    protected $paymentMethod;
87
88
    /**
89
     * Because the fee can change on the payment method we have a field for here for the fee on this order
90
     *
91
     * @var integer|null
92
     *
93
     * @ORM\Column(type="integer", nullable=true)
94
     */
95
    protected $paymentMethodFee;
96
97
    /**
98
     * @var ShippingMethodInterface|null
99
     *
100
     * @ORM\JoinColumn(onDelete="SET NULL")
101
     * @ORM\ManyToOne(targetEntity="ShippingMethod", cascade={"persist", "remove"})
102
     */
103
    protected $shippingMethod;
104
105
    /**
106
     * Because the fee can change on the shipping method we have a field for here for the fee on this order
107
     *
108
     * @var integer|null
109
     *
110
     * @ORM\Column(type="integer", nullable=true)
111
     */
112
    protected $shippingMethodFee;
113
114
    /**
115
     * @var SiteInterface|null
116
     *
117
     * @ORM\JoinColumn(onDelete="SET NULL")
118
     * @ORM\ManyToOne(targetEntity="Site", cascade={"persist", "remove"})
119
     */
120
    protected $site;
121
122
    /**
123
     * @var StateInterface|null
124
     *
125
     * @ORM\JoinColumn(onDelete="SET NULL")
126
     * @ORM\ManyToOne(targetEntity="State", cascade={"persist", "remove"})
127
     */
128
    protected $state;
129
130
    /**
131
     * @var string|null
132
     *
133
     * @ORM\Column(nullable=true, type="text")
134
     */
135
    protected $comment;
136
137
    /**
138
     * @var \DateTimeImmutable|null
139
     *
140
     * @ORM\Column(nullable=true, type="datetime_immutable")
141
     */
142
    protected $createdDate;
143
144
    /**
145
     * @var string|null
146
     *
147
     * @ORM\Column(nullable=true, type="string", length=191)
148
     */
149
    protected $creditNoteNumber;
150
151
    /**
152
     * @var string|null
153
     *
154
     * @ORM\Column(type="string", length=3, nullable=true)
155
     */
156
    protected $currencyCode;
157
158
    /**
159
     * @var string|null
160
     *
161
     * @ORM\Column(nullable=true, type="text")
162
     */
163
    protected $customerComment;
164
165
    /**
166
     * @var integer|null
167
     *
168
     * @ORM\Column(type="integer", nullable=true)
169
     */
170
    protected $giftCertificateAmount;
171
172
    /**
173
     * @var string|null
174
     *
175
     * @ORM\Column(nullable=true, type="string", length=191)
176
     */
177
    protected $giftCertificateNumber;
178
179
    /**
180
     * @var bool|null
181
     *
182
     * @ORM\Column(type="boolean", nullable=true)
183
     */
184
    protected $incomplete;
185
186
    /**
187
     * @var string|null
188
     *
189
     * @ORM\Column(nullable=true, type="string", length=191)
190
     */
191
    protected $ip;
192
193
    /**
194
     * @var bool|null
195
     *
196
     * @ORM\Column(type="boolean", nullable=true)
197
     */
198
    protected $modified;
199
200
    /**
201
     * @var \DateTimeImmutable|null
202
     *
203
     * @ORM\Column(nullable=true, type="datetime_immutable")
204
     */
205
    protected $modifiedDate;
206
207
    /**
208
     * @var string|null
209
     *
210
     * @ORM\Column(nullable=true, type="string", length=191)
211
     */
212
    protected $referenceNumber;
213
214
    /**
215
     * @var string|null
216
     *
217
     * @ORM\Column(nullable=true, type="string", length=191)
218
     */
219
    protected $referrer;
220
221
    /**
222
     * @var string|null
223
     *
224
     * @ORM\Column(nullable=true, type="string", length=191)
225
     */
226
    protected $reservedField1;
227
228
    /**
229
     * @var string|null
230
     *
231
     * @ORM\Column(nullable=true, type="string", length=191)
232
     */
233
    protected $reservedField2;
234
235
    /**
236
     * @var string|null
237
     *
238
     * @ORM\Column(nullable=true, type="string", length=191)
239
     */
240
    protected $reservedField3;
241
242
    /**
243
     * @var string|null
244
     *
245
     * @ORM\Column(nullable=true, type="string", length=191)
246
     */
247
    protected $reservedField4;
248
249
    /**
250
     * @var string|null
251
     *
252
     * @ORM\Column(nullable=true, type="string", length=191)
253
     */
254
    protected $reservedField5;
255
256
    /**
257
     * @var int|null
258
     *
259
     * @ORM\Column(type="integer", nullable=true)
260
     */
261
    protected $salesDiscount;
262
263
    /**
264
     * @var int|null
265
     *
266
     * @ORM\Column(type="integer", nullable=true)
267
     */
268
    protected $totalPrice;
269
270
    /**
271
     * @var float|null
272
     *
273
     * @ORM\Column(nullable=true, type="decimal", precision=12, scale=2)
274
     */
275
    protected $totalWeight;
276
277
    /**
278
     * @var string|null
279
     *
280
     * @ORM\Column(nullable=true, type="string", length=191)
281
     */
282
    protected $trackingNumber;
283
284
    /**
285
     * @var int|null
286
     *
287
     * @ORM\Column(nullable=true, type="string", length=191)
288
     */
289
    protected $transactionNumber;
290
291
    /**
292
     * @var float|null
293
     *
294
     * @ORM\Column(nullable=true, type="decimal", precision=5, scale=2)
295
     */
296
    protected $vatPct;
297
298
    /**
299
     * @var string|null
300
     *
301
     * @ORM\Column(nullable=true, type="string", length=191)
302
     */
303
    protected $vatRegNumber;
304
305
    /**
306
     * @var string|null
307
     *
308
     * @ORM\Column(nullable=true, type="text")
309
     */
310
    protected $xmlParams;
311
312
    public function __construct()
313
    {
314
        $this->orderLines = new ArrayCollection();
315
    }
316
317
    /**
318
     * Populates an order based on the response from the Dandomain API
319
     *
320
     * See the properties here:
321
     * http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/OrderService/help/operations/GetOrder
322
     *
323
     * @param \stdClass|array $data
324
     * @param bool $populateEmbedded
325
     * @return OrderInterface
326
     */
327
    public function populateFromApiResponse($data, bool $populateEmbedded = false) : OrderInterface
328
    {
329
        $data = DandomainFoundation\objectToArray($data);
330
331
        // set currency because we use the currency to create Money objects
332
        $this->setCurrencyCode($data['currencyCode']);
333
334
        // set shortcuts for embedded objects
335
        $orderLinesData = $data['orderLines'] ?? [];
0 ignored issues
show
Unused Code introduced by
The assignment to $orderLinesData is dead and can be removed.
Loading history...
336
        $paymentData = $data['paymentInfo'] ?? [];
337
        $shippingData = $data['shippingInfo'] ?? [];
338
339
        $createdDate = DateTimeImmutable::createFromJson($data['createdDate']);
340
        $modifiedDate = DateTimeImmutable::createFromJson($data['modifiedDate']);
341
342
        $giftCertificateAmount = $this->createMoneyFromFloat($data['giftCertificateAmount']);
343
        $totalPrice = $this->createMoneyFromFloat($data['totalPrice']);
344
        $salesDiscount = $this->createMoneyFromFloat($data['salesDiscount']);
345
        $paymentMethodFee = $this->createMoneyFromFloat($paymentData['fee'] ?? 0.0);
346
        $shippingMethodFee = $this->createMoneyFromFloat($shippingData['fee'] ?? 0.0);
347
348
        $this
349
            ->setExternalId($data['id'])
0 ignored issues
show
Bug introduced by
It seems like $data['id'] can also be of type string; however, parameter $externalId of Loevgaard\DandomainFound...\Order::setExternalId() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

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

349
            ->setExternalId(/** @scrutinizer ignore-type */ $data['id'])
Loading history...
350
            ->setComment($data['comment'])
351
            ->setCreatedDate($createdDate)
352
            ->setCustomerComment($data['customerComment'])
353
            ->setGiftCertificateAmount($giftCertificateAmount)
354
            ->setGiftCertificateNumber($data['giftCertificateNumber'])
355
            ->setIncomplete($data['incomplete'])
0 ignored issues
show
Bug introduced by
It seems like $data['incomplete'] can also be of type string; however, parameter $incomplete of Loevgaard\DandomainFound...\Order::setIncomplete() does only seem to accept null|boolean, maybe add an additional type check? ( Ignorable by Annotation )

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

355
            ->setIncomplete(/** @scrutinizer ignore-type */ $data['incomplete'])
Loading history...
356
            ->setIp($data['ip'])
357
            ->setModified($data['modified'])
0 ignored issues
show
Bug introduced by
It seems like $data['modified'] can also be of type string; however, parameter $modified of Loevgaard\DandomainFound...ty\Order::setModified() does only seem to accept null|boolean, maybe add an additional type check? ( Ignorable by Annotation )

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

357
            ->setModified(/** @scrutinizer ignore-type */ $data['modified'])
Loading history...
358
            ->setModifiedDate($modifiedDate)
359
            ->setReferenceNumber($data['referenceNumber'])
360
            ->setReferrer($data['referrer'])
361
            ->setReservedField1($data['reservedField1'])
362
            ->setReservedField2($data['reservedField2'])
363
            ->setReservedField3($data['reservedField3'])
364
            ->setReservedField4($data['reservedField4'])
365
            ->setReservedField5($data['reservedField5'])
366
            ->setSalesDiscount($salesDiscount)
367
            ->setTotalPrice($totalPrice)
368
            ->setTotalWeight($data['totalWeight'])
0 ignored issues
show
Bug introduced by
It seems like $data['totalWeight'] can also be of type string; however, parameter $totalWeight of Loevgaard\DandomainFound...Order::setTotalWeight() does only seem to accept null|double, maybe add an additional type check? ( Ignorable by Annotation )

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

368
            ->setTotalWeight(/** @scrutinizer ignore-type */ $data['totalWeight'])
Loading history...
369
            ->setTrackingNumber($data['trackingNumber'])
370
            ->setTransactionNumber($data['transactionNumber'])
0 ignored issues
show
Bug introduced by
It seems like $data['transactionNumber'] can also be of type string; however, parameter $transactionNumber of Loevgaard\DandomainFound...:setTransactionNumber() does only seem to accept null|integer, maybe add an additional type check? ( Ignorable by Annotation )

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

370
            ->setTransactionNumber(/** @scrutinizer ignore-type */ $data['transactionNumber'])
Loading history...
371
            ->setVatPct($data['vatPct'])
0 ignored issues
show
Bug introduced by
It seems like $data['vatPct'] can also be of type string; however, parameter $vatPct of Loevgaard\DandomainFound...tity\Order::setVatPct() does only seem to accept null|double, maybe add an additional type check? ( Ignorable by Annotation )

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

371
            ->setVatPct(/** @scrutinizer ignore-type */ $data['vatPct'])
Loading history...
372
            ->setVatRegNumber($data['vatRegNumber'])
373
            ->setXmlParams($data['xmlParams'])
374
            ->setShippingMethodFee($shippingMethodFee)
375
            ->setPaymentMethodFee($paymentMethodFee)
376
        ;
377
378
        if ($populateEmbedded) {
379
            // populate customer
380
            $customer = $this->getCustomer();
381
            if (!$customer) {
382
                $customer = new Customer();
383
                $this->setCustomer($customer);
384
            }
385
            $customer->populateFromApiResponse($data['customerInfo']);
0 ignored issues
show
Bug introduced by
It seems like $data['customerInfo'] can also be of type string; however, parameter $data of Loevgaard\DandomainFound...pulateFromApiResponse() does only seem to accept stdClass|array, maybe add an additional type check? ( Ignorable by Annotation )

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

385
            $customer->populateFromApiResponse(/** @scrutinizer ignore-type */ $data['customerInfo']);
Loading history...
Bug introduced by
It seems like $data['customerInfo'] can also be of type string; however, parameter $data of Loevgaard\DandomainFound...pulateFromApiResponse() does only seem to accept stdClass|array, maybe add an additional type check? ( Ignorable by Annotation )

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

385
            $customer->populateFromApiResponse(/** @scrutinizer ignore-type */ $data['customerInfo']);
Loading history...
386
387
            // populate delivery info
388
            $delivery = $this->getDelivery();
389
            if (!$delivery) {
390
                $delivery = new Delivery();
391
                $this->setDelivery($delivery);
392
            }
393
            $delivery->populateFromApiResponse($data['deliveryInfo']);
0 ignored issues
show
Bug introduced by
It seems like $data['deliveryInfo'] can also be of type string; however, parameter $data of Loevgaard\DandomainFound...pulateFromApiResponse() does only seem to accept stdClass|array, maybe add an additional type check? ( Ignorable by Annotation )

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

393
            $delivery->populateFromApiResponse(/** @scrutinizer ignore-type */ $data['deliveryInfo']);
Loading history...
Bug introduced by
It seems like $data['deliveryInfo'] can also be of type string; however, parameter $data of Loevgaard\DandomainFound...pulateFromApiResponse() does only seem to accept stdClass|array, maybe add an additional type check? ( Ignorable by Annotation )

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

393
            $delivery->populateFromApiResponse(/** @scrutinizer ignore-type */ $data['deliveryInfo']);
Loading history...
394
395
            // populate invoice info
396
            $invoice = $this->getInvoice();
397
            if (!$invoice) {
398
                $invoice = new Invoice();
399
                $this->setInvoice($invoice);
400
            }
401
            $invoice->populateFromApiResponse($data['invoiceInfo']);
0 ignored issues
show
Bug introduced by
It seems like $data['invoiceInfo'] can also be of type string; however, parameter $data of Loevgaard\DandomainFound...pulateFromApiResponse() does only seem to accept stdClass|array, maybe add an additional type check? ( Ignorable by Annotation )

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

401
            $invoice->populateFromApiResponse(/** @scrutinizer ignore-type */ $data['invoiceInfo']);
Loading history...
Bug introduced by
It seems like $data['invoiceInfo'] can also be of type string; however, parameter $data of Loevgaard\DandomainFound...pulateFromApiResponse() does only seem to accept stdClass|array, maybe add an additional type check? ( Ignorable by Annotation )

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

401
            $invoice->populateFromApiResponse(/** @scrutinizer ignore-type */ $data['invoiceInfo']);
Loading history...
402
403
            // populate payment info
404
            $paymentMethod = $this->getPaymentMethod();
405
            if (!$paymentMethod) {
406
                $paymentMethod = new PaymentMethod();
407
                $paymentMethod->populateFromApiResponse($data['paymentInfo'], (string)$data['currencyCode']);
0 ignored issues
show
Bug introduced by
It seems like $data['paymentInfo'] can also be of type string; however, parameter $data of Loevgaard\DandomainFound...pulateFromApiResponse() does only seem to accept stdClass|array, maybe add an additional type check? ( Ignorable by Annotation )

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

407
                $paymentMethod->populateFromApiResponse(/** @scrutinizer ignore-type */ $data['paymentInfo'], (string)$data['currencyCode']);
Loading history...
408
            }
409
            $this->setPaymentMethod($paymentMethod);
410
411
            // populate shipping info
412
            $shippingMethod = $this->getShippingMethod();
413
            if (!$shippingMethod) {
414
                $shippingMethod = new ShippingMethod();
415
                $shippingMethod->populateFromApiResponse($data['shippingInfo'], (string)$data['currencyCode']);
0 ignored issues
show
Bug introduced by
It seems like $data['shippingInfo'] can also be of type string; however, parameter $data of Loevgaard\DandomainFound...pulateFromApiResponse() does only seem to accept stdClass|array, maybe add an additional type check? ( Ignorable by Annotation )

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

415
                $shippingMethod->populateFromApiResponse(/** @scrutinizer ignore-type */ $data['shippingInfo'], (string)$data['currencyCode']);
Loading history...
416
            }
417
            $this->setShippingMethod($shippingMethod);
418
419
            // populate site
420
            $site = $this->getSite();
421
            if (!$site) {
422
                $site = new Site();
423
                $site->setExternalId($data['siteId']);
0 ignored issues
show
Bug introduced by
It seems like $data['siteId'] can also be of type string; however, parameter $externalId of Loevgaard\DandomainFound...y\Site::setExternalId() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

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

423
                $site->setExternalId(/** @scrutinizer ignore-type */ $data['siteId']);
Loading history...
424
            }
425
            $this->setSite($site);
426
427
            // populate state
428
            $state = $this->getState();
429
            if (!$state) {
430
                $state = new State();
431
                $state->populateFromApiResponse($data['orderState']);
0 ignored issues
show
Bug introduced by
It seems like $data['orderState'] can also be of type string; however, parameter $data of Loevgaard\DandomainFound...pulateFromApiResponse() does only seem to accept stdClass|array, maybe add an additional type check? ( Ignorable by Annotation )

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

431
                $state->populateFromApiResponse(/** @scrutinizer ignore-type */ $data['orderState']);
Loading history...
432
            }
433
            $this->setState($state);
434
435
            // @todo create order lines
436
        }
437
438
        return $this;
439
    }
440
441
    /*
442
     * Collection methods
443
     */
444
    public function addOrderLine(OrderLineInterface $orderLine) : OrderInterface
445
    {
446
        if(!$this->hasOrderLine($orderLine)) {
447
            $this->orderLines->add($orderLine);
448
            $orderLine->setOrder($this);
449
        }
450
        return $this;
451
    }
452
453
    public function hasOrderLine(OrderLineInterface $orderLine) : bool
454
    {
455
        return $this->orderLines->exists(function($key, OrderLineInterface $element) use ($orderLine) {
456
            return $element->getExternalId() === $orderLine->getExternalId();
457
        });
458
    }
459
460
    public function removeOrderLine(OrderLineInterface $orderLine) : OrderInterface
461
    {
462
        $orderLine->setOrder(null);
0 ignored issues
show
Bug introduced by
null of type null is incompatible with the type Loevgaard\DandomainFoundation\Entity\Order expected by parameter $order of Loevgaard\DandomainFound...neInterface::setOrder(). ( Ignorable by Annotation )

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

462
        $orderLine->setOrder(/** @scrutinizer ignore-type */ null);
Loading history...
463
        $this->orderLines->removeElement($orderLine);
464
        return $this;
465
    }
466
467
    /*
468
     * Getters / Setters
469
     */
470
    /**
471
     * @return Money|null
472
     */
473
    public function getTotalPrice() : ?Money
474
    {
475
        return $this->createMoney((int)$this->totalPrice);
476
    }
477
478
    /**
479
     * @param Money $money
480
     * @return OrderInterface
481
     */
482
    public function setTotalPrice(Money $money = null) : OrderInterface
483
    {
484
        $this->totalPrice = $money->getAmount();
0 ignored issues
show
Documentation Bug introduced by
It seems like $money->getAmount() of type string is incompatible with the declared type null|integer of property $totalPrice.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
Bug introduced by
The method getAmount() does not exist on null. ( Ignorable by Annotation )

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

484
        /** @scrutinizer ignore-call */ 
485
        $this->totalPrice = $money->getAmount();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
485
486
        return $this;
487
    }
488
489
    /**
490
     * @return Money|null
491
     */
492
    public function getSalesDiscount() : ?Money
493
    {
494
        return $this->createMoney((int)$this->salesDiscount);
495
    }
496
497
    /**
498
     * @param Money $money
499
     * @return OrderInterface
500
     */
501
    public function setSalesDiscount(Money $money = null) : OrderInterface
502
    {
503
        $this->salesDiscount = $money->getAmount();
0 ignored issues
show
Documentation Bug introduced by
It seems like $money->getAmount() of type string is incompatible with the declared type null|integer of property $salesDiscount.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
504
505
        return $this;
506
    }
507
508
    /**
509
     * @return Money|null
510
     */
511
    public function getGiftCertificateAmount() : ?Money
512
    {
513
        return $this->createMoney((int)$this->giftCertificateAmount);
514
    }
515
516
    /**
517
     * @param Money $money
518
     * @return OrderInterface
519
     */
520
    public function setGiftCertificateAmount(Money $money = null) : OrderInterface
521
    {
522
        $this->giftCertificateAmount = $money->getAmount();
0 ignored issues
show
Documentation Bug introduced by
It seems like $money->getAmount() of type string is incompatible with the declared type null|integer of property $giftCertificateAmount.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
523
524
        return $this;
525
    }
526
527
    /**
528
     * @return Money|null
529
     */
530
    public function getShippingMethodFee() : ?Money
531
    {
532
        return $this->createMoney((int)$this->shippingMethodFee);
533
    }
534
535
    /**
536
     * @param Money $money
537
     * @return OrderInterface
538
     */
539
    public function setShippingMethodFee(Money $money = null) : OrderInterface
540
    {
541
        $this->shippingMethodFee = $money->getAmount();
0 ignored issues
show
Documentation Bug introduced by
It seems like $money->getAmount() of type string is incompatible with the declared type null|integer of property $shippingMethodFee.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
542
543
        return $this;
544
    }
545
546
    /**
547
     * @return Money|null
548
     */
549
    public function getPaymentMethodFee() : ?Money
550
    {
551
        return $this->createMoney((int)$this->paymentMethodFee);
552
    }
553
554
    /**
555
     * @param Money $money
556
     * @return OrderInterface
557
     */
558
    public function setPaymentMethodFee(Money $money = null) : OrderInterface
559
    {
560
        $this->paymentMethodFee = $money->getAmount();
0 ignored issues
show
Documentation Bug introduced by
It seems like $money->getAmount() of type string is incompatible with the declared type null|integer of property $paymentMethodFee.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
561
562
        return $this;
563
    }
564
565
    /**
566
     * @return int
567
     */
568
    public function getId(): int
569
    {
570
        return (int)$this->id;
571
    }
572
573
    /**
574
     * @param int $id
575
     * @return OrderInterface
576
     */
577
    public function setId($id)
578
    {
579
        $this->id = $id;
580
        return $this;
581
    }
582
583
    /**
584
     * @return int
585
     */
586
    public function getExternalId(): int
587
    {
588
        return $this->externalId;
589
    }
590
591
    /**
592
     * @param int $externalId
593
     * @return OrderInterface
594
     */
595
    public function setExternalId($externalId)
596
    {
597
        $this->externalId = $externalId;
598
        return $this;
599
    }
600
601
    /**
602
     * @return CustomerInterface|null
603
     */
604
    public function getCustomer()
605
    {
606
        return $this->customer;
607
    }
608
609
    /**
610
     * @param CustomerInterface|null $customer
611
     * @return OrderInterface
612
     */
613
    public function setCustomer($customer)
614
    {
615
        $this->customer = $customer;
616
        return $this;
617
    }
618
619
    /**
620
     * @return DeliveryInterface|null
621
     */
622
    public function getDelivery()
623
    {
624
        return $this->delivery;
625
    }
626
627
    /**
628
     * @param DeliveryInterface|null $delivery
629
     * @return OrderInterface
630
     */
631
    public function setDelivery($delivery)
632
    {
633
        $this->delivery = $delivery;
634
        return $this;
635
    }
636
637
    /**
638
     * @return InvoiceInterface|null
639
     */
640
    public function getInvoice()
641
    {
642
        return $this->invoice;
643
    }
644
645
    /**
646
     * @param InvoiceInterface|null $invoice
647
     * @return OrderInterface
648
     */
649
    public function setInvoice($invoice)
650
    {
651
        $this->invoice = $invoice;
652
        return $this;
653
    }
654
655
    /**
656
     * @return ArrayCollection|null
657
     */
658
    public function getOrderLines()
659
    {
660
        return $this->orderLines;
661
    }
662
663
    /**
664
     * @param ArrayCollection|null $orderLines
665
     * @return OrderInterface
666
     */
667
    public function setOrderLines($orderLines)
668
    {
669
        $this->orderLines = $orderLines;
670
        return $this;
671
    }
672
673
    /**
674
     * @return PaymentMethodInterface|null
675
     */
676
    public function getPaymentMethod()
677
    {
678
        return $this->paymentMethod;
679
    }
680
681
    /**
682
     * @param PaymentMethodInterface|null $paymentMethod
683
     * @return OrderInterface
684
     */
685
    public function setPaymentMethod($paymentMethod)
686
    {
687
        $this->paymentMethod = $paymentMethod;
688
        return $this;
689
    }
690
691
    /**
692
     * @return ShippingMethodInterface|null
693
     */
694
    public function getShippingMethod()
695
    {
696
        return $this->shippingMethod;
697
    }
698
699
    /**
700
     * @param ShippingMethodInterface|null $shippingMethod
701
     * @return OrderInterface
702
     */
703
    public function setShippingMethod($shippingMethod)
704
    {
705
        $this->shippingMethod = $shippingMethod;
706
        return $this;
707
    }
708
709
    /**
710
     * @return SiteInterface|null
711
     */
712
    public function getSite()
713
    {
714
        return $this->site;
715
    }
716
717
    /**
718
     * @param SiteInterface|null $site
719
     * @return OrderInterface
720
     */
721
    public function setSite($site)
722
    {
723
        $this->site = $site;
724
        return $this;
725
    }
726
727
    /**
728
     * @return StateInterface|null
729
     */
730
    public function getState()
731
    {
732
        return $this->state;
733
    }
734
735
    /**
736
     * @param StateInterface|null $state
737
     * @return OrderInterface
738
     */
739
    public function setState($state)
740
    {
741
        $this->state = $state;
742
        return $this;
743
    }
744
745
    /**
746
     * @return null|string
747
     */
748
    public function getComment()
749
    {
750
        return $this->comment;
751
    }
752
753
    /**
754
     * @param null|string $comment
755
     * @return OrderInterface
756
     */
757
    public function setComment($comment)
758
    {
759
        $this->comment = $comment;
760
        return $this;
761
    }
762
763
    /**
764
     * @return \DateTimeImmutable|null
765
     */
766
    public function getCreatedDate()
767
    {
768
        return $this->createdDate;
769
    }
770
771
    /**
772
     * @param \DateTimeImmutable|null $createdDate
773
     * @return OrderInterface
774
     */
775
    public function setCreatedDate($createdDate)
776
    {
777
        $this->createdDate = $createdDate;
778
        return $this;
779
    }
780
781
    /**
782
     * @return null|string
783
     */
784
    public function getCreditNoteNumber()
785
    {
786
        return $this->creditNoteNumber;
787
    }
788
789
    /**
790
     * @param null|string $creditNoteNumber
791
     * @return Order
792
     */
793
    public function setCreditNoteNumber($creditNoteNumber)
794
    {
795
        $this->creditNoteNumber = $creditNoteNumber;
796
        return $this;
797
    }
798
799
    /**
800
     * @return null|string
801
     */
802
    public function getCurrencyCode()
803
    {
804
        return $this->currencyCode;
805
    }
806
807
    /**
808
     * @param null|string $currencyCode
809
     * @return OrderInterface
810
     */
811
    public function setCurrencyCode($currencyCode)
812
    {
813
        $this->currencyCode = $currencyCode;
814
        return $this;
815
    }
816
817
    /**
818
     * @return null|string
819
     */
820
    public function getCustomerComment()
821
    {
822
        return $this->customerComment;
823
    }
824
825
    /**
826
     * @param null|string $customerComment
827
     * @return OrderInterface
828
     */
829
    public function setCustomerComment($customerComment)
830
    {
831
        $this->customerComment = $customerComment;
832
        return $this;
833
    }
834
835
    /**
836
     * @return null|string
837
     */
838
    public function getGiftCertificateNumber()
839
    {
840
        return $this->giftCertificateNumber;
841
    }
842
843
    /**
844
     * @param null|string $giftCertificateNumber
845
     * @return OrderInterface
846
     */
847
    public function setGiftCertificateNumber($giftCertificateNumber)
848
    {
849
        $this->giftCertificateNumber = $giftCertificateNumber;
850
        return $this;
851
    }
852
853
    /**
854
     * @return bool|null
855
     */
856
    public function getIncomplete()
857
    {
858
        return $this->incomplete;
859
    }
860
861
    /**
862
     * @param bool|null $incomplete
863
     * @return OrderInterface
864
     */
865
    public function setIncomplete($incomplete)
866
    {
867
        $this->incomplete = $incomplete;
868
        return $this;
869
    }
870
871
    /**
872
     * @return null|string
873
     */
874
    public function getIp()
875
    {
876
        return $this->ip;
877
    }
878
879
    /**
880
     * @param null|string $ip
881
     * @return OrderInterface
882
     */
883
    public function setIp($ip)
884
    {
885
        $this->ip = $ip;
886
        return $this;
887
    }
888
889
    /**
890
     * @return bool|null
891
     */
892
    public function getModified()
893
    {
894
        return $this->modified;
895
    }
896
897
    /**
898
     * @param bool|null $modified
899
     * @return OrderInterface
900
     */
901
    public function setModified($modified)
902
    {
903
        $this->modified = $modified;
904
        return $this;
905
    }
906
907
    /**
908
     * @return \DateTimeImmutable|null
909
     */
910
    public function getModifiedDate()
911
    {
912
        return $this->modifiedDate;
913
    }
914
915
    /**
916
     * @param \DateTimeImmutable|null $modifiedDate
917
     * @return OrderInterface
918
     */
919
    public function setModifiedDate($modifiedDate)
920
    {
921
        $this->modifiedDate = $modifiedDate;
922
        return $this;
923
    }
924
925
    /**
926
     * @return null|string
927
     */
928
    public function getReferenceNumber()
929
    {
930
        return $this->referenceNumber;
931
    }
932
933
    /**
934
     * @param null|string $referenceNumber
935
     * @return OrderInterface
936
     */
937
    public function setReferenceNumber($referenceNumber)
938
    {
939
        $this->referenceNumber = $referenceNumber;
940
        return $this;
941
    }
942
943
    /**
944
     * @return null|string
945
     */
946
    public function getReferrer()
947
    {
948
        return $this->referrer;
949
    }
950
951
    /**
952
     * @param null|string $referrer
953
     * @return OrderInterface
954
     */
955
    public function setReferrer($referrer)
956
    {
957
        $this->referrer = $referrer;
958
        return $this;
959
    }
960
961
    /**
962
     * @return null|string
963
     */
964
    public function getReservedField1()
965
    {
966
        return $this->reservedField1;
967
    }
968
969
    /**
970
     * @param null|string $reservedField1
971
     * @return OrderInterface
972
     */
973
    public function setReservedField1($reservedField1)
974
    {
975
        $this->reservedField1 = $reservedField1;
976
        return $this;
977
    }
978
979
    /**
980
     * @return null|string
981
     */
982
    public function getReservedField2()
983
    {
984
        return $this->reservedField2;
985
    }
986
987
    /**
988
     * @param null|string $reservedField2
989
     * @return OrderInterface
990
     */
991
    public function setReservedField2($reservedField2)
992
    {
993
        $this->reservedField2 = $reservedField2;
994
        return $this;
995
    }
996
997
    /**
998
     * @return null|string
999
     */
1000
    public function getReservedField3()
1001
    {
1002
        return $this->reservedField3;
1003
    }
1004
1005
    /**
1006
     * @param null|string $reservedField3
1007
     * @return OrderInterface
1008
     */
1009
    public function setReservedField3($reservedField3)
1010
    {
1011
        $this->reservedField3 = $reservedField3;
1012
        return $this;
1013
    }
1014
1015
    /**
1016
     * @return null|string
1017
     */
1018
    public function getReservedField4()
1019
    {
1020
        return $this->reservedField4;
1021
    }
1022
1023
    /**
1024
     * @param null|string $reservedField4
1025
     * @return OrderInterface
1026
     */
1027
    public function setReservedField4($reservedField4)
1028
    {
1029
        $this->reservedField4 = $reservedField4;
1030
        return $this;
1031
    }
1032
1033
    /**
1034
     * @return null|string
1035
     */
1036
    public function getReservedField5()
1037
    {
1038
        return $this->reservedField5;
1039
    }
1040
1041
    /**
1042
     * @param null|string $reservedField5
1043
     * @return OrderInterface
1044
     */
1045
    public function setReservedField5($reservedField5)
1046
    {
1047
        $this->reservedField5 = $reservedField5;
1048
        return $this;
1049
    }
1050
1051
    /**
1052
     * @return float|null
1053
     */
1054
    public function getTotalWeight()
1055
    {
1056
        return $this->totalWeight;
1057
    }
1058
1059
    /**
1060
     * @param float|null $totalWeight
1061
     * @return OrderInterface
1062
     */
1063
    public function setTotalWeight($totalWeight)
1064
    {
1065
        $this->totalWeight = $totalWeight;
1066
        return $this;
1067
    }
1068
1069
    /**
1070
     * @return null|string
1071
     */
1072
    public function getTrackingNumber()
1073
    {
1074
        return $this->trackingNumber;
1075
    }
1076
1077
    /**
1078
     * @param null|string $trackingNumber
1079
     * @return OrderInterface
1080
     */
1081
    public function setTrackingNumber($trackingNumber)
1082
    {
1083
        $this->trackingNumber = $trackingNumber;
1084
        return $this;
1085
    }
1086
1087
    /**
1088
     * @return int|null
1089
     */
1090
    public function getTransactionNumber()
1091
    {
1092
        return $this->transactionNumber;
1093
    }
1094
1095
    /**
1096
     * @param int|null $transactionNumber
1097
     * @return OrderInterface
1098
     */
1099
    public function setTransactionNumber($transactionNumber)
1100
    {
1101
        $this->transactionNumber = $transactionNumber;
1102
        return $this;
1103
    }
1104
1105
    /**
1106
     * @return float|null
1107
     */
1108
    public function getVatPct()
1109
    {
1110
        return $this->vatPct;
1111
    }
1112
1113
    /**
1114
     * @param float|null $vatPct
1115
     * @return OrderInterface
1116
     */
1117
    public function setVatPct($vatPct)
1118
    {
1119
        $this->vatPct = $vatPct;
1120
        return $this;
1121
    }
1122
1123
    /**
1124
     * @return null|string
1125
     */
1126
    public function getVatRegNumber()
1127
    {
1128
        return $this->vatRegNumber;
1129
    }
1130
1131
    /**
1132
     * @param null|string $vatRegNumber
1133
     * @return OrderInterface
1134
     */
1135
    public function setVatRegNumber($vatRegNumber)
1136
    {
1137
        $this->vatRegNumber = $vatRegNumber;
1138
        return $this;
1139
    }
1140
1141
    /**
1142
     * @return null|string
1143
     */
1144
    public function getXmlParams()
1145
    {
1146
        return $this->xmlParams;
1147
    }
1148
1149
    /**
1150
     * @param null|string $xmlParams
1151
     * @return OrderInterface
1152
     */
1153
    public function setXmlParams($xmlParams)
1154
    {
1155
        $this->xmlParams = $xmlParams;
1156
        return $this;
1157
    }
1158
1159
    /**
1160
     * A helper method for creating a Money object from a float based on the shared currency
1161
     *
1162
     * @param int $amount
1163
     * @return Money|null
1164
     */
1165
    private function createMoney(int $amount = 0) : ?Money
1166
    {
1167
        return DandomainFoundation\createMoney((string)$this->currencyCode, $amount);
1168
    }
1169
1170
    /**
1171
     * A helper method for creating a Money object from a float based on the shared currency
1172
     *
1173
     * @param float|string $amount
1174
     * @return Money|null
1175
     */
1176
    private function createMoneyFromFloat($amount = 0.0) : ?Money
1177
    {
1178
        return DandomainFoundation\createMoneyFromFloat((string)$this->currencyCode, $amount);
1179
    }
1180
}
1181