Completed
Push — master ( 8e0b0c...5c217b )
by Joachim
22:48 queued 07:52
created

Order::getCurrency()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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

336
            $data['totalPrice'] = /** @scrutinizer ignore-call */ DandomainFoundation\createMoneyFromFloat($currency, $data['totalPrice']);
Loading history...
337
        }
338 3
339 3
        if (isset($data['giftCertificateAmount'])) {
340
            $data['giftCertificateAmount'] = DandomainFoundation\createMoneyFromFloat($currency, $data['giftCertificateAmount']);
341
        }
342 3
343 3
        if (isset($data['salesDiscount'])) {
344
            $data['salesDiscount'] = DandomainFoundation\createMoneyFromFloat($currency, $data['salesDiscount']);
345
        }
346 3
347 3
        if (isset($data['paymentInfo']['fee'])) {
348
            $data['paymentMethodFee'] = DandomainFoundation\createMoneyFromFloat($currency, $data['paymentInfo']['fee']);
349
        }
350 3
351 3
        if (isset($data['shippingInfo']['fee'])) {
352
            $data['shippingMethodFee'] = DandomainFoundation\createMoneyFromFloat($currency, $data['shippingInfo']['fee']);
353
        }
354 3
355 3
        if ($data['createdDate']) {
356
            $data['createdDate'] = $this->getDateTimeFromJson($data['createdDate']);
357
        }
358 3
359 3
        if ($data['modifiedDate']) {
360
            $data['modifiedDate'] = $this->getDateTimeFromJson($data['modifiedDate']);
361
        }
362
363
        parent::hydrate($data, $useConversions, $scalarsOnly);
364
    }
365
366
    /*
367
     * Helper methods
368
     */
369
    public function getTotalPriceInclVat() : ?Money
370
    {
371
        return $this->getTotalPrice();
372
    }
373
374
    public function getTotalPriceExclVat() : ?Money
375
    {
376
        $totalPrice = $this->getTotalPrice();
377
        if (!$totalPrice) {
378
            return null;
379
        }
380
381
        $multiplier = 100 / (100 + $this->vatPct);
382
383
        return $totalPrice->multiply($multiplier);
384
    }
385
386
    public function totalPriceWithoutFees() : ?Money
387
    {
388
        $totalPrice = $this->getTotalPrice();
389
        if (!$totalPrice) {
390
            return null;
391
        }
392
393
        $paymentMethodFee = $this->getPaymentMethodFee();
394
        if ($paymentMethodFee) {
395
            $totalPrice = $totalPrice->subtract($paymentMethodFee);
396
        }
397
398
        $shippingMethodFee = $this->getShippingMethodFee();
399
        if ($shippingMethodFee) {
400
            $totalPrice = $totalPrice->subtract($shippingMethodFee);
401
        }
402
403
        return $totalPrice;
404 15
    }
405
406 15
    /*
407 15
     * Collection methods
408 15
     */
409
    public function addOrderLine(OrderLineInterface $orderLine) : OrderInterface
410
    {
411 15
        if (!$this->hasOrderLine($orderLine)) {
412
            $this->orderLines->add($orderLine);
413
            $orderLine->setOrder($this);
414
        }
415
416
        return $this;
417
    }
418 15
419
    /**
420 15
     * @param OrderLineInterface|int $orderLine Either the OrderLineInterface or the external id
421 15
     * @return bool
422
     */
423
    public function hasOrderLine($orderLine) : bool
424 15
    {
425 9
        if ($orderLine instanceof OrderLineInterface) {
426 15
            $orderLine = $orderLine->getExternalId();
427
        }
428
429 6
        return $this->orderLines->exists(function ($key, OrderLineInterface $element) use ($orderLine) {
430
            return $element->getExternalId() === $orderLine;
431 6
        });
432
    }
433 6
434
    public function removeOrderLine(OrderLineInterface $orderLine) : OrderInterface
435
    {
436 3
        $this->orderLines->removeElement($orderLine);
437
438 3
        return $this;
439 3
    }
440
441
    public function clearOrderLines() : OrderInterface
442 3
    {
443
        foreach ($this->orderLines as $orderLine) {
444
            $this->removeOrderLine($orderLine);
445
        }
446
447
        return $this;
448
    }
449
450
    /*
451 3
     * Getters / Setters
452
     */
453 3
    /**
454
     * @return Money|null
455
     */
456
    public function getTotalPrice() : ?Money
457
    {
458
        return $this->createMoney((int)$this->totalPrice);
459
    }
460 3
461
    /**
462 3
     * @param Money $money
463
     * @return OrderInterface
464 3
     */
465
    public function setTotalPrice(Money $money = null) : OrderInterface
466
    {
467
        $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

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

1154
        return /** @scrutinizer ignore-call */ DandomainFoundation\createMoney($this->currency->getIsoCodeAlpha(), $amount);
Loading history...
1155
    }
1156
}
1157