Completed
Push — master ( 9396da...236110 )
by Joachim
15:12
created

Order::hydrate()   D

Complexity

Conditions 8
Paths 128

Size

Total Lines 33
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 8.125

Importance

Changes 0
Metric Value
cc 8
eloc 16
nc 128
nop 3
dl 0
loc 33
ccs 14
cts 16
cp 0.875
crap 8.125
rs 4.6666
c 0
b 0
f 0
1
<?php
2
3
namespace Loevgaard\DandomainFoundation\Entity;
4
5
use Brick\Math\BigDecimal;
6
use Doctrine\Common\Collections\ArrayCollection;
7
use Doctrine\ORM\Mapping as ORM;
8
use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletable;
9
use Knp\DoctrineBehaviors\Model\Timestampable\Timestampable;
10
use Loevgaard\DandomainFoundation;
11
use Loevgaard\DandomainFoundation\Entity\Generated\CurrencyInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...rated\CurrencyInterface 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 Loevgaard\DandomainFoundation\Entity\Generated\CustomerInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...rated\CustomerInterface 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 Loevgaard\DandomainFoundation\Entity\Generated\DeliveryInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...rated\DeliveryInterface 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 Loevgaard\DandomainFoundation\Entity\Generated\InvoiceInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...erated\InvoiceInterface 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 Loevgaard\DandomainFoundation\Entity\Generated\OrderInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...enerated\OrderInterface 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...
16
use Loevgaard\DandomainFoundation\Entity\Generated\OrderLineInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...ated\OrderLineInterface 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...
17
use Loevgaard\DandomainFoundation\Entity\Generated\OrderTrait;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...ty\Generated\OrderTrait 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...
18
use Loevgaard\DandomainFoundation\Entity\Generated\PaymentMethodInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...\PaymentMethodInterface 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...
19
use Loevgaard\DandomainFoundation\Entity\Generated\ShippingMethodInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...ShippingMethodInterface 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...
20
use Loevgaard\DandomainFoundation\Entity\Generated\SiteInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...Generated\SiteInterface 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...
21
use Loevgaard\DandomainFoundation\Entity\Generated\StateInterface;
0 ignored issues
show
Bug introduced by
The type Loevgaard\DandomainFound...enerated\StateInterface 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...
22
use Money\Money;
23
24
/**
25
 * We use the Money library for amounts, and we use a shared currency, namely the property $currencyCode.
26
 *
27
 * @ORM\Entity()
28
 * @ORM\Table(name="ldf_orders", uniqueConstraints={
29
 *     @ORM\UniqueConstraint(name="external_id", columns={"external_id"})
30
 * })
31
 */
32
class Order extends AbstractEntity implements OrderInterface
33
{
34
    use OrderTrait;
35
    use Timestampable;
36
    use SoftDeletable;
37
38
    protected $hydrateConversions = [
39
        'id' => 'externalId',
40
    ];
41
42
    /**
43
     * @var int
44
     *
45
     * @ORM\Id
46
     * @ORM\GeneratedValue
47
     * @ORM\Column(type="integer")
48
     **/
49
    protected $id;
50
51
    /**
52
     * This is the order id in Dandomain.
53
     *
54
     * @var int
55
     *
56
     * @ORM\Column(type="integer")
57
     */
58
    protected $externalId;
59
60
    /**
61
     * @var CustomerInterface|null
62
     *
63
     * @ORM\JoinColumn(onDelete="SET NULL")
64
     * @ORM\ManyToOne(targetEntity="Customer", cascade={"persist", "remove"})
65
     */
66
    protected $customer;
67
68
    /**
69
     * @var DeliveryInterface|null
70
     *
71
     * @ORM\JoinColumn(onDelete="SET NULL")
72
     * @ORM\ManyToOne(targetEntity="Delivery", cascade={"persist", "remove"})
73
     */
74
    protected $delivery;
75
76
    /**
77
     * @var InvoiceInterface|null
78
     *
79
     * @ORM\JoinColumn(onDelete="SET NULL")
80
     * @ORM\ManyToOne(targetEntity="Invoice", cascade={"persist", "remove"})
81
     */
82
    protected $invoice;
83
84
    /**
85
     * @var OrderLineInterface[]|ArrayCollection
86
     *
87
     * @ORM\OneToMany(mappedBy="order", targetEntity="OrderLine", cascade={"persist", "remove"}, orphanRemoval=true)
88
     */
89
    protected $orderLines;
90
91
    /**
92
     * @var PaymentMethodInterface|null
93
     *
94
     * @ORM\JoinColumn(onDelete="SET NULL")
95
     * @ORM\ManyToOne(targetEntity="PaymentMethod", cascade={"persist", "remove"})
96
     */
97
    protected $paymentMethod;
98
99
    /**
100
     * Because the fee can change on the payment method we have a field for here for the fee on this order.
101
     *
102
     * @var int|null
103
     *
104
     * @ORM\Column(type="integer", nullable=true)
105
     */
106
    protected $paymentMethodFee;
107
108
    /**
109
     * @var ShippingMethodInterface|null
110
     *
111
     * @ORM\JoinColumn(onDelete="SET NULL")
112
     * @ORM\ManyToOne(targetEntity="ShippingMethod", cascade={"persist", "remove"})
113
     */
114
    protected $shippingMethod;
115
116
    /**
117
     * Because the fee can change on the shipping method we have a field for here for the fee on this order.
118
     *
119
     * @var int|null
120
     *
121
     * @ORM\Column(type="integer", nullable=true)
122
     */
123
    protected $shippingMethodFee;
124
125
    /**
126
     * @var SiteInterface|null
127
     *
128
     * @ORM\JoinColumn(onDelete="SET NULL")
129
     * @ORM\ManyToOne(targetEntity="Site", cascade={"persist", "remove"})
130
     */
131
    protected $site;
132
133
    /**
134
     * @var StateInterface|null
135
     *
136
     * @ORM\JoinColumn(onDelete="SET NULL")
137
     * @ORM\ManyToOne(targetEntity="State", cascade={"persist", "remove"})
138
     */
139
    protected $state;
140
141
    /**
142
     * @var string|null
143
     *
144
     * @ORM\Column(nullable=true, type="text")
145
     */
146
    protected $comment;
147
148
    /**
149
     * @var \DateTimeImmutable|null
150
     *
151
     * @ORM\Column(nullable=true, type="datetime_immutable", options={"comment"="Created info from Dandomain"})
152
     */
153
    protected $createdDate;
154
155
    /**
156
     * @var string|null
157
     *
158
     * @ORM\Column(nullable=true, type="string", length=191)
159
     */
160
    protected $creditNoteNumber;
161
162
    /**
163
     * The currency code in the Dandomain API refers in fact to the currencies' field named 'id' or 'code'
164
     * Therefore we don't have a currencyCode property, but a currency property.
165
     *
166
     * @var CurrencyInterface|null
167
     *
168
     * @ORM\ManyToOne(targetEntity="Currency")
169
     * @ORM\JoinColumn(nullable=false)
170
     */
171
    protected $currency;
172
173
    /**
174
     * @var string|null
175
     *
176
     * @ORM\Column(nullable=true, type="text")
177
     */
178
    protected $customerComment;
179
180
    /**
181
     * @var int|null
182
     *
183
     * @ORM\Column(type="integer", nullable=true)
184
     */
185
    protected $giftCertificateAmount;
186
187
    /**
188
     * @var string|null
189
     *
190
     * @ORM\Column(nullable=true, type="string", length=191)
191
     */
192
    protected $giftCertificateNumber;
193
194
    /**
195
     * @var bool|null
196
     *
197
     * @ORM\Column(type="boolean", nullable=true)
198
     */
199
    protected $incomplete;
200
201
    /**
202
     * @var string|null
203
     *
204
     * @ORM\Column(nullable=true, type="string", length=191)
205
     */
206
    protected $ip;
207
208
    /**
209
     * @var bool|null
210
     *
211
     * @ORM\Column(type="boolean", nullable=true)
212
     */
213
    protected $modified;
214
215
    /**
216
     * @var \DateTimeImmutable|null
217
     *
218
     * @ORM\Column(nullable=true, type="datetime_immutable", options={"comment"="Modified info from Dandomain"})
219
     */
220
    protected $modifiedDate;
221
222
    /**
223
     * @var string|null
224
     *
225
     * @ORM\Column(nullable=true, type="string", length=191)
226
     */
227
    protected $referenceNumber;
228
229
    /**
230
     * @var string|null
231
     *
232
     * @ORM\Column(nullable=true, type="text")
233
     */
234
    protected $referrer;
235
236
    /**
237
     * @var string|null
238
     *
239
     * @ORM\Column(nullable=true, type="string", length=191)
240
     */
241
    protected $reservedField1;
242
243
    /**
244
     * @var string|null
245
     *
246
     * @ORM\Column(nullable=true, type="string", length=191)
247
     */
248
    protected $reservedField2;
249
250
    /**
251
     * @var string|null
252
     *
253
     * @ORM\Column(nullable=true, type="string", length=191)
254
     */
255
    protected $reservedField3;
256
257
    /**
258
     * @var string|null
259
     *
260
     * @ORM\Column(nullable=true, type="string", length=191)
261
     */
262
    protected $reservedField4;
263
264
    /**
265
     * @var string|null
266
     *
267
     * @ORM\Column(nullable=true, type="string", length=191)
268
     */
269
    protected $reservedField5;
270
271
    /**
272
     * @var int|null
273
     *
274
     * @ORM\Column(type="integer", nullable=true)
275
     */
276
    protected $salesDiscount;
277
278
    /**
279
     * This price is incl vat.
280
     *
281
     * @var int|null
282
     *
283
     * @ORM\Column(type="integer", nullable=true)
284
     */
285
    protected $totalPrice;
286
287
    /**
288
     * @var float|null
289
     *
290
     * @ORM\Column(nullable=true, type="decimal", precision=12, scale=2)
291
     */
292
    protected $totalWeight;
293
294
    /**
295
     * @var string|null
296
     *
297
     * @ORM\Column(nullable=true, type="string", length=191)
298
     */
299
    protected $trackingNumber;
300
301
    /**
302
     * @var int|null
303
     *
304
     * @ORM\Column(nullable=true, type="string", length=191)
305
     */
306
    protected $transactionNumber;
307
308
    /**
309
     * @var float|null
310
     *
311
     * @ORM\Column(nullable=true, type="decimal", precision=5, scale=2)
312
     */
313
    protected $vatPct;
314
315
    /**
316
     * @var string|null
317
     *
318
     * @ORM\Column(nullable=true, type="string", length=191)
319
     */
320
    protected $vatRegNumber;
321 27
322
    /**
323 27
     * @var string|null
324 27
     *
325
     * @ORM\Column(nullable=true, type="text")
326 3
     */
327
    protected $xmlParams;
328 3
329
    public function __construct()
330 3
    {
331 3
        $this->orderLines = new ArrayCollection();
332
    }
333
334 3
    public function hydrate(array $data, bool $useConversions = false, $scalarsOnly = true)
335 3
    {
336
        $currency = $data['currencyCode'];
337
338 3
        if (isset($data['totalPrice'])) {
339 3
            $data['totalPrice'] = DandomainFoundation\createMoneyFromFloat($currency, $data['totalPrice']);
0 ignored issues
show
Bug introduced by
The function createMoneyFromFloat was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

339
            $data['totalPrice'] = /** @scrutinizer ignore-call */ DandomainFoundation\createMoneyFromFloat($currency, $data['totalPrice']);
Loading history...
340
        }
341
342 3
        if (isset($data['giftCertificateAmount'])) {
343 3
            $data['giftCertificateAmount'] = DandomainFoundation\createMoneyFromFloat($currency, $data['giftCertificateAmount']);
344
        }
345
346 3
        if (isset($data['salesDiscount'])) {
347 3
            $data['salesDiscount'] = DandomainFoundation\createMoneyFromFloat($currency, $data['salesDiscount']);
348
        }
349
350 3
        if (isset($data['paymentInfo']['fee'])) {
351 3
            $data['paymentMethodFee'] = DandomainFoundation\createMoneyFromFloat($currency, $data['paymentInfo']['fee']);
352
        }
353
354 3
        if (isset($data['shippingInfo']['fee'])) {
355 3
            $data['shippingMethodFee'] = DandomainFoundation\createMoneyFromFloat($currency, $data['shippingInfo']['fee']);
356
        }
357
358 3
        if ($data['createdDate']) {
359 3
            $data['createdDate'] = $this->getDateTimeFromJson($data['createdDate']);
360
        }
361
362
        if ($data['modifiedDate']) {
363
            $data['modifiedDate'] = $this->getDateTimeFromJson($data['modifiedDate']);
364
        }
365
366
        parent::hydrate($data, $useConversions, $scalarsOnly);
367
    }
368
369
    /*
370
     * Helper methods
371
     */
372
    public function getTotalPriceInclVat(): ?Money
373
    {
374
        return $this->getTotalPrice();
375
    }
376
377
    public function getTotalPriceExclVat(): ?Money
378
    {
379
        $totalPrice = $this->getTotalPrice();
380
        if (!$totalPrice) {
381
            return null;
382
        }
383
384
        $multiplier = BigDecimal::of('100')->exactlyDividedBy(BigDecimal::of('100')->plus($this->vatPct));
0 ignored issues
show
Bug introduced by
The method exactlyDividedBy() does not exist on Brick\Math\BigRational. ( Ignorable by Annotation )

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

384
        $multiplier = BigDecimal::of('100')->/** @scrutinizer ignore-call */ exactlyDividedBy(BigDecimal::of('100')->plus($this->vatPct));

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...
Bug introduced by
The method exactlyDividedBy() does not exist on Brick\Math\BigInteger. ( Ignorable by Annotation )

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

384
        $multiplier = BigDecimal::of('100')->/** @scrutinizer ignore-call */ exactlyDividedBy(BigDecimal::of('100')->plus($this->vatPct));

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...
385
386
        return $totalPrice->multiply((string) $multiplier);
387
    }
388
389
    public function totalPriceWithoutFees(): ?Money
390
    {
391
        $totalPrice = $this->getTotalPrice();
392
        if (!$totalPrice) {
393
            return null;
394
        }
395
396
        $paymentMethodFee = $this->getPaymentMethodFee();
397
        if ($paymentMethodFee) {
398
            $totalPrice = $totalPrice->subtract($paymentMethodFee);
399
        }
400
401
        $shippingMethodFee = $this->getShippingMethodFee();
402
        if ($shippingMethodFee) {
403
            $totalPrice = $totalPrice->subtract($shippingMethodFee);
404 15
        }
405
406 15
        return $totalPrice;
407 15
    }
408 15
409
    /*
410
     * Collection methods
411 15
     */
412
    public function addOrderLine(OrderLineInterface $orderLine): OrderInterface
413
    {
414
        if (!$this->hasOrderLine($orderLine)) {
415
            $this->orderLines->add($orderLine);
416
            $orderLine->setOrder($this);
417
        }
418 15
419
        return $this;
420 15
    }
421 15
422
    /**
423
     * @param OrderLineInterface|int $orderLine Either the OrderLineInterface or the external id
424 15
     *
425 9
     * @return bool
426 15
     */
427
    public function hasOrderLine($orderLine): bool
428
    {
429 6
        if ($orderLine instanceof OrderLineInterface) {
430
            $orderLine = $orderLine->getExternalId();
431 6
        }
432
433 6
        return $this->orderLines->exists(function ($key, OrderLineInterface $element) use ($orderLine) {
434
            return $element->getExternalId() === $orderLine;
435
        });
436 3
    }
437
438 3
    public function removeOrderLine(OrderLineInterface $orderLine): OrderInterface
439 3
    {
440
        $orderLine->setOrder(null);
441
        $this->orderLines->removeElement($orderLine);
442 3
443
        return $this;
444
    }
445
446
    public function clearOrderLines(): OrderInterface
447
    {
448
        foreach ($this->orderLines as $orderLine) {
449
            $orderLine->setOrder(null);
450
        }
451 3
452
        $this->orderLines->clear();
453 3
454
        return $this;
455
    }
456
457
    /**
458
     * @param OrderLineInterface[] $orderLines
459
     */
460 3
    public function updateOrderLines(array $orderLines): void
461
    {
462 3
        // this holds the final array of order lines, whether updated or added
463
        $final = [];
464 3
        foreach ($orderLines as $orderLine) {
465
            $existing = $this->findOrderLine($orderLine);
466
            if ($existing) {
467
                $existing->copyProperties($orderLine);
468
                $existing->setOrder($this);
469
                $final[] = $existing;
470 3
            } else {
471
                $this->addOrderLine($orderLine);
472 3
                $final[] = $orderLine;
473
            }
474
        }
475
476
        foreach ($this->orderLines as $orderLine) {
477
            if (!in_array($orderLine, $final, true)) {
478
                $this->removeOrderLine($orderLine);
479 3
            }
480
        }
481 3
    }
482
483 3
    /*
484
     * Getters / Setters
485
     */
486
487
    /**
488
     * @return Money|null
489 3
     */
490
    public function getTotalPrice(): ?Money
491 3
    {
492
        return $this->createMoney((int) $this->totalPrice);
493
    }
494
495
    /**
496
     * @param Money $money
497
     *
498 3
     * @return OrderInterface
499
     */
500 3
    public function setTotalPrice(Money $money = null): OrderInterface
501
    {
502 3
        $this->totalPrice = $money->getAmount();
0 ignored issues
show
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

502
        /** @scrutinizer ignore-call */ 
503
        $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...
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...
503
504
        return $this;
505
    }
506
507
    /**
508 3
     * @return Money|null
509
     */
510 3
    public function getSalesDiscount(): ?Money
511
    {
512
        return $this->createMoney((int) $this->salesDiscount);
513
    }
514
515
    /**
516
     * @param Money $money
517 3
     *
518
     * @return OrderInterface
519 3
     */
520
    public function setSalesDiscount(Money $money = null): OrderInterface
521 3
    {
522
        $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...
523
524
        return $this;
525
    }
526
527 3
    /**
528
     * @return Money|null
529 3
     */
530
    public function getGiftCertificateAmount(): ?Money
531
    {
532
        return $this->createMoney((int) $this->giftCertificateAmount);
533
    }
534
535
    /**
536 3
     * @param Money $money
537
     *
538 3
     * @return OrderInterface
539
     */
540 3
    public function setGiftCertificateAmount(Money $money = null): OrderInterface
541
    {
542
        $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...
543
544
        return $this;
545
    }
546 6
547
    /**
548 6
     * @return Money|null
549
     */
550
    public function getShippingMethodFee(): ?Money
551
    {
552
        return $this->createMoney((int) $this->shippingMethodFee);
553
    }
554
555 3
    /**
556
     * @param Money $money
557 3
     *
558 3
     * @return OrderInterface
559
     */
560
    public function setShippingMethodFee(Money $money = null): OrderInterface
561
    {
562
        $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...
563
564 6
        return $this;
565
    }
566 6
567
    /**
568
     * @return Money|null
569
     */
570
    public function getPaymentMethodFee(): ?Money
571
    {
572
        return $this->createMoney((int) $this->paymentMethodFee);
573 3
    }
574
575 3
    /**
576 3
     * @param Money $money
577
     *
578
     * @return OrderInterface
579
     */
580
    public function setPaymentMethodFee(Money $money = null): OrderInterface
581
    {
582 3
        $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...
583
584 3
        return $this;
585
    }
586
587
    /**
588
     * @return int
589
     */
590
    public function getId(): int
591 3
    {
592
        return (int) $this->id;
593 3
    }
594 3
595
    /**
596
     * @param int $id
597
     *
598
     * @return OrderInterface
599
     */
600 3
    public function setId($id)
601
    {
602 3
        $this->id = $id;
603
604
        return $this;
605
    }
606
607
    /**
608
     * @return int
609 3
     */
610
    public function getExternalId(): int
611 3
    {
612 3
        return (int) $this->externalId;
613
    }
614
615
    /**
616
     * @param int $externalId
617
     *
618 3
     * @return OrderInterface
619
     */
620 3
    public function setExternalId($externalId)
621
    {
622
        $this->externalId = $externalId;
623
624
        return $this;
625
    }
626
627 3
    /**
628
     * @return CustomerInterface|null
629 3
     */
630 3
    public function getCustomer()
631
    {
632
        return $this->customer;
633
    }
634
635
    /**
636 12
     * @param CustomerInterface|null $customer
637
     *
638 12
     * @return OrderInterface
639
     */
640
    public function setCustomer($customer)
641
    {
642
        $this->customer = $customer;
643
644
        return $this;
645 3
    }
646
647 3
    /**
648 3
     * @return DeliveryInterface|null
649
     */
650
    public function getDelivery()
651
    {
652
        return $this->delivery;
653
    }
654 3
655
    /**
656 3
     * @param DeliveryInterface|null $delivery
657
     *
658
     * @return OrderInterface
659
     */
660
    public function setDelivery($delivery)
661
    {
662
        $this->delivery = $delivery;
663 3
664
        return $this;
665 3
    }
666 3
667
    /**
668
     * @return InvoiceInterface|null
669
     */
670
    public function getInvoice()
671
    {
672 3
        return $this->invoice;
673
    }
674 3
675
    /**
676
     * @param InvoiceInterface|null $invoice
677
     *
678
     * @return OrderInterface
679
     */
680
    public function setInvoice($invoice)
681 3
    {
682
        $this->invoice = $invoice;
683 3
684 3
        return $this;
685
    }
686
687
    /**
688
     * @return ArrayCollection|OrderLineInterface[]
689
     */
690 3
    public function getOrderLines()
691
    {
692 3
        return $this->orderLines;
693
    }
694
695
    /**
696
     * @param ArrayCollection|null $orderLines
697
     *
698
     * @return OrderInterface
699 3
     */
700
    public function setOrderLines($orderLines)
701 3
    {
702 3
        $this->orderLines = $orderLines;
703
704
        return $this;
705
    }
706
707
    /**
708 3
     * @return PaymentMethodInterface|null
709
     */
710 3
    public function getPaymentMethod()
711
    {
712
        return $this->paymentMethod;
713
    }
714
715
    /**
716
     * @param PaymentMethodInterface|null $paymentMethod
717 3
     *
718
     * @return OrderInterface
719 3
     */
720 3
    public function setPaymentMethod($paymentMethod)
721
    {
722
        $this->paymentMethod = $paymentMethod;
723
724
        return $this;
725
    }
726 3
727
    /**
728 3
     * @return ShippingMethodInterface|null
729
     */
730
    public function getShippingMethod()
731
    {
732
        return $this->shippingMethod;
733
    }
734
735 3
    /**
736
     * @param ShippingMethodInterface|null $shippingMethod
737 3
     *
738 3
     * @return OrderInterface
739
     */
740
    public function setShippingMethod($shippingMethod)
741
    {
742
        $this->shippingMethod = $shippingMethod;
743
744 3
        return $this;
745
    }
746 3
747
    /**
748
     * @return SiteInterface|null
749
     */
750
    public function getSite()
751
    {
752
        return $this->site;
753 3
    }
754
755 3
    /**
756 3
     * @param SiteInterface|null $site
757
     *
758
     * @return OrderInterface
759
     */
760
    public function setSite($site)
761
    {
762 3
        $this->site = $site;
763
764 3
        return $this;
765
    }
766
767
    /**
768
     * @return StateInterface|null
769
     */
770
    public function getState()
771 3
    {
772
        return $this->state;
773 3
    }
774 3
775
    /**
776
     * @param StateInterface|null $state
777
     *
778
     * @return OrderInterface
779
     */
780 6
    public function setState($state)
781
    {
782 6
        $this->state = $state;
783
784
        return $this;
785
    }
786
787
    /**
788
     * @return null|string
789 6
     */
790
    public function getComment()
791 6
    {
792 6
        return $this->comment;
793
    }
794
795
    /**
796
     * @param null|string $comment
797
     *
798 3
     * @return OrderInterface
799
     */
800 3
    public function setComment($comment)
801
    {
802
        $this->comment = $comment;
803
804
        return $this;
805
    }
806
807 3
    /**
808
     * @return \DateTimeImmutable|null
809 3
     */
810 3
    public function getCreatedDate()
811
    {
812
        return $this->createdDate;
813
    }
814
815
    /**
816 3
     * @param \DateTimeImmutable|null $createdDate
817
     *
818 3
     * @return OrderInterface
819
     */
820
    public function setCreatedDate($createdDate)
821
    {
822
        $this->createdDate = $createdDate;
823
824
        return $this;
825 3
    }
826
827 3
    /**
828 3
     * @return null|string
829
     */
830
    public function getCreditNoteNumber()
831
    {
832
        return $this->creditNoteNumber;
833
    }
834 3
835
    /**
836 3
     * @param null|string $creditNoteNumber
837
     *
838
     * @return Order
839
     */
840
    public function setCreditNoteNumber($creditNoteNumber)
841
    {
842
        $this->creditNoteNumber = $creditNoteNumber;
843 3
844
        return $this;
845 3
    }
846 3
847
    /**
848
     * @return CurrencyInterface|null
849
     */
850
    public function getCurrency()
851
    {
852 3
        return $this->currency;
853
    }
854 3
855
    /**
856
     * @param null|CurrencyInterface $currency
857
     *
858
     * @return OrderInterface
859
     */
860
    public function setCurrency($currency)
861 3
    {
862
        $this->currency = $currency;
863 3
864 3
        return $this;
865
    }
866
867
    /**
868
     * @return null|string
869
     */
870 3
    public function getCustomerComment()
871
    {
872 3
        return $this->customerComment;
873
    }
874
875
    /**
876
     * @param null|string $customerComment
877
     *
878
     * @return OrderInterface
879 3
     */
880
    public function setCustomerComment($customerComment)
881 3
    {
882 3
        $this->customerComment = $customerComment;
883
884
        return $this;
885
    }
886
887
    /**
888 3
     * @return null|string
889
     */
890 3
    public function getGiftCertificateNumber()
891
    {
892
        return $this->giftCertificateNumber;
893
    }
894
895
    /**
896
     * @param null|string $giftCertificateNumber
897 3
     *
898
     * @return OrderInterface
899 3
     */
900 3
    public function setGiftCertificateNumber($giftCertificateNumber)
901
    {
902
        $this->giftCertificateNumber = $giftCertificateNumber;
903
904
        return $this;
905
    }
906 3
907
    /**
908 3
     * @return bool|null
909
     */
910
    public function getIncomplete()
911
    {
912
        return $this->incomplete;
913
    }
914
915 3
    /**
916
     * @param bool|null $incomplete
917 3
     *
918 3
     * @return OrderInterface
919
     */
920
    public function setIncomplete($incomplete)
921
    {
922
        $this->incomplete = $incomplete;
923
924 3
        return $this;
925
    }
926 3
927
    /**
928
     * @return null|string
929
     */
930
    public function getIp()
931
    {
932
        return $this->ip;
933 3
    }
934
935 3
    /**
936 3
     * @param null|string $ip
937
     *
938
     * @return OrderInterface
939
     */
940
    public function setIp($ip)
941
    {
942 3
        $this->ip = $ip;
943
944 3
        return $this;
945
    }
946
947
    /**
948
     * @return bool|null
949
     */
950
    public function getModified()
951 3
    {
952
        return $this->modified;
953 3
    }
954 3
955
    /**
956
     * @param bool|null $modified
957
     *
958
     * @return OrderInterface
959
     */
960 3
    public function setModified($modified)
961
    {
962 3
        $this->modified = $modified;
963
964
        return $this;
965
    }
966
967
    /**
968
     * @return \DateTimeImmutable|null
969 3
     */
970
    public function getModifiedDate()
971 3
    {
972 3
        return $this->modifiedDate;
973
    }
974
975
    /**
976
     * @param \DateTimeImmutable|null $modifiedDate
977
     *
978 3
     * @return OrderInterface
979
     */
980 3
    public function setModifiedDate($modifiedDate)
981
    {
982
        $this->modifiedDate = $modifiedDate;
983
984
        return $this;
985
    }
986
987 3
    /**
988
     * @return null|string
989 3
     */
990 3
    public function getReferenceNumber()
991
    {
992
        return $this->referenceNumber;
993
    }
994
995
    /**
996 3
     * @param null|string $referenceNumber
997
     *
998 3
     * @return OrderInterface
999
     */
1000
    public function setReferenceNumber($referenceNumber)
1001
    {
1002
        $this->referenceNumber = $referenceNumber;
1003
1004
        return $this;
1005 3
    }
1006
1007 3
    /**
1008 3
     * @return null|string
1009
     */
1010
    public function getReferrer()
1011
    {
1012
        return $this->referrer;
1013
    }
1014 3
1015
    /**
1016 3
     * @param null|string $referrer
1017
     *
1018
     * @return OrderInterface
1019
     */
1020
    public function setReferrer($referrer)
1021
    {
1022
        $this->referrer = $referrer;
1023 3
1024
        return $this;
1025 3
    }
1026 3
1027
    /**
1028
     * @return null|string
1029
     */
1030
    public function getReservedField1()
1031
    {
1032 3
        return $this->reservedField1;
1033
    }
1034 3
1035
    /**
1036
     * @param null|string $reservedField1
1037
     *
1038
     * @return OrderInterface
1039
     */
1040
    public function setReservedField1($reservedField1)
1041 3
    {
1042
        $this->reservedField1 = $reservedField1;
1043 3
1044 3
        return $this;
1045
    }
1046
1047
    /**
1048
     * @return null|string
1049
     */
1050 3
    public function getReservedField2()
1051
    {
1052 3
        return $this->reservedField2;
1053
    }
1054
1055
    /**
1056
     * @param null|string $reservedField2
1057
     *
1058
     * @return OrderInterface
1059 3
     */
1060
    public function setReservedField2($reservedField2)
1061 3
    {
1062 3
        $this->reservedField2 = $reservedField2;
1063
1064
        return $this;
1065
    }
1066
1067
    /**
1068 3
     * @return null|string
1069
     */
1070 3
    public function getReservedField3()
1071
    {
1072
        return $this->reservedField3;
1073
    }
1074
1075
    /**
1076
     * @param null|string $reservedField3
1077 3
     *
1078
     * @return OrderInterface
1079 3
     */
1080 3
    public function setReservedField3($reservedField3)
1081
    {
1082
        $this->reservedField3 = $reservedField3;
1083
1084
        return $this;
1085
    }
1086 3
1087
    /**
1088 3
     * @return null|string
1089
     */
1090
    public function getReservedField4()
1091
    {
1092
        return $this->reservedField4;
1093
    }
1094
1095 3
    /**
1096
     * @param null|string $reservedField4
1097 3
     *
1098 3
     * @return OrderInterface
1099
     */
1100
    public function setReservedField4($reservedField4)
1101
    {
1102
        $this->reservedField4 = $reservedField4;
1103
1104 3
        return $this;
1105
    }
1106 3
1107
    /**
1108
     * @return null|string
1109
     */
1110
    public function getReservedField5()
1111
    {
1112
        return $this->reservedField5;
1113 3
    }
1114
1115 3
    /**
1116 3
     * @param null|string $reservedField5
1117
     *
1118
     * @return OrderInterface
1119
     */
1120
    public function setReservedField5($reservedField5)
1121
    {
1122 3
        $this->reservedField5 = $reservedField5;
1123
1124 3
        return $this;
1125
    }
1126
1127
    /**
1128
     * @return float|null
1129
     */
1130
    public function getTotalWeight()
1131 3
    {
1132
        return $this->totalWeight;
1133 3
    }
1134 3
1135
    /**
1136
     * @param float|null $totalWeight
1137
     *
1138
     * @return OrderInterface
1139
     */
1140
    public function setTotalWeight($totalWeight)
1141
    {
1142
        $this->totalWeight = $totalWeight;
1143 3
1144
        return $this;
1145 3
    }
1146
1147
    /**
1148
     * @return null|string
1149
     */
1150
    public function getTrackingNumber()
1151
    {
1152
        return $this->trackingNumber;
1153
    }
1154
1155
    /**
1156
     * @param null|string $trackingNumber
1157
     *
1158
     * @return OrderInterface
1159
     */
1160
    public function setTrackingNumber($trackingNumber)
1161
    {
1162
        $this->trackingNumber = $trackingNumber;
1163
1164
        return $this;
1165
    }
1166
1167
    /**
1168
     * @return int|null
1169
     */
1170
    public function getTransactionNumber()
1171
    {
1172
        return $this->transactionNumber;
1173
    }
1174
1175
    /**
1176
     * @param int|null $transactionNumber
1177
     *
1178
     * @return OrderInterface
1179
     */
1180
    public function setTransactionNumber($transactionNumber)
1181
    {
1182
        $this->transactionNumber = $transactionNumber;
1183
1184
        return $this;
1185
    }
1186
1187
    /**
1188
     * @return float|null
1189
     */
1190
    public function getVatPct()
1191
    {
1192
        return $this->vatPct;
1193
    }
1194
1195
    /**
1196
     * @param float|null $vatPct
1197
     *
1198
     * @return OrderInterface
1199
     */
1200
    public function setVatPct($vatPct)
1201
    {
1202
        $this->vatPct = $vatPct;
1203
1204
        return $this;
1205
    }
1206
1207
    /**
1208
     * @return null|string
1209
     */
1210
    public function getVatRegNumber()
1211
    {
1212
        return $this->vatRegNumber;
1213
    }
1214
1215
    /**
1216
     * @param null|string $vatRegNumber
1217
     *
1218
     * @return OrderInterface
1219
     */
1220
    public function setVatRegNumber($vatRegNumber)
1221
    {
1222
        $this->vatRegNumber = $vatRegNumber;
1223
1224
        return $this;
1225
    }
1226
1227
    /**
1228
     * @return null|string
1229
     */
1230
    public function getXmlParams()
1231
    {
1232
        return $this->xmlParams;
1233
    }
1234
1235
    /**
1236
     * @param null|string $xmlParams
1237
     *
1238
     * @return OrderInterface
1239
     */
1240
    public function setXmlParams($xmlParams)
1241
    {
1242
        $this->xmlParams = $xmlParams;
1243
1244
        return $this;
1245
    }
1246
1247
    protected function findOrderLine(OrderLineInterface $orderLine): ?OrderLineInterface
1248
    {
1249
        foreach ($this->orderLines as $ol) {
1250
            if ($orderLine->getExternalId() === $ol->getExternalId()) {
1251
                return $ol;
1252
            }
1253
        }
1254
1255
        return null;
1256
    }
1257
1258
    /**
1259
     * A helper method for creating a Money object from a float based on the shared currency.
1260
     *
1261
     * @param int $amount
1262
     *
1263
     * @return Money|null
1264
     */
1265
    private function createMoney(int $amount = 0): ?Money
1266
    {
1267
        if (!$this->currency) {
1268
            return null;
1269
        }
1270
1271
        return DandomainFoundation\createMoney($this->currency->getIsoCodeAlpha(), $amount);
0 ignored issues
show
Bug introduced by
The function createMoney was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

1271
        return /** @scrutinizer ignore-call */ DandomainFoundation\createMoney($this->currency->getIsoCodeAlpha(), $amount);
Loading history...
1272
    }
1273
}
1274