Completed
Push — master ( 86baa2...e4c715 )
by Joachim
02:36
created

Payment::getTotalAmount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Loevgaard\Dandomain\Pay\Model;
4
5
use Money\Currency;
6
use Money\Money;
7
use Psr\Http\Message\ServerRequestInterface;
8
9
class Payment
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $apiKey;
15
16
    /**
17
     * @var string
18
     */
19
    protected $merchant;
20
21
    /**
22
     * @var int
23
     */
24
    protected $orderId;
25
26
    /**
27
     * @var string
28
     */
29
    protected $sessionId;
30
31
    /**
32
     * @var string
33
     */
34
    protected $currencySymbol;
35
36
    /**
37
     * @var Money
38
     */
39
    protected $totalAmount;
40
41
    /**
42
     * @var string
43
     */
44
    protected $callBackUrl;
45
46
    /**
47
     * @var string
48
     */
49
    protected $fullCallBackOkUrl;
50
51
    /**
52
     * @var string
53
     */
54
    protected $callBackOkUrl;
55
56
    /**
57
     * @var string
58
     */
59
    protected $callBackServerUrl;
60
61
    /**
62
     * @var int
63
     */
64
    protected $languageId;
65
66
    /**
67
     * @var bool
68
     */
69
    protected $testMode;
70
71
    /**
72
     * @var int
73
     */
74
    protected $paymentGatewayCurrencyCode;
75
76
    /**
77
     * @var int
78
     */
79
    protected $cardTypeId;
80
81
    /**
82
     * @var string
83
     */
84
    protected $customerRekvNr;
85
86
    /**
87
     * @var string
88
     */
89
    protected $customerName;
90
91
    /**
92
     * @var string
93
     */
94
    protected $customerCompany;
95
96
    /**
97
     * @var string
98
     */
99
    protected $customerAddress;
100
101
    /**
102
     * @var string
103
     */
104
    protected $customerAddress2;
105
106
    /**
107
     * @var string
108
     */
109
    protected $customerZipCode;
110
111
    /**
112
     * @var string
113
     */
114
    protected $customerCity;
115
116
    /**
117
     * @var int
118
     */
119
    protected $customerCountryId;
120
121
    /**
122
     * @var string
123
     */
124
    protected $customerCountry;
125
126
    /**
127
     * @var string
128
     */
129
    protected $customerPhone;
130
131
    /**
132
     * @var string
133
     */
134
    protected $customerFax;
135
136
    /**
137
     * @var string
138
     */
139
    protected $customerEmail;
140
141
    /**
142
     * @var string
143
     */
144
    protected $customerNote;
145
146
    /**
147
     * @var string
148
     */
149
    protected $customerCvrnr;
150
151
    /**
152
     * @var int
153
     */
154
    protected $customerCustTypeId;
155
156
    /**
157
     * @var string
158
     */
159
    protected $customerEan;
160
161
    /**
162
     * @var string
163
     */
164
    protected $customerRes1;
165
166
    /**
167
     * @var string
168
     */
169
    protected $customerRes2;
170
171
    /**
172
     * @var string
173
     */
174
    protected $customerRes3;
175
176
    /**
177
     * @var string
178
     */
179
    protected $customerRes4;
180
181
    /**
182
     * @var string
183
     */
184
    protected $customerRes5;
185
186
    /**
187
     * @var string
188
     */
189
    protected $customerIp;
190
191
    /**
192
     * @var string
193
     */
194
    protected $deliveryName;
195
196
    /**
197
     * @var string
198
     */
199
    protected $deliveryCompany;
200
201
    /**
202
     * @var string
203
     */
204
    protected $deliveryAddress;
205
206
    /**
207
     * @var string
208
     */
209
    protected $deliveryAddress2;
210
211
    /**
212
     * @var string
213
     */
214
    protected $deliveryZipCode;
215
216
    /**
217
     * @var string
218
     */
219
    protected $deliveryCity;
220
221
    /**
222
     * @var int
223
     */
224
    protected $deliveryCountryID;
225
226
    /**
227
     * @var string
228
     */
229
    protected $deliveryCountry;
230
231
    /**
232
     * @var string
233
     */
234
    protected $deliveryPhone;
235
236
    /**
237
     * @var string
238
     */
239
    protected $deliveryFax;
240
241
    /**
242
     * @var string
243
     */
244
    protected $deliveryEmail;
245
246
    /**
247
     * @var string
248
     */
249
    protected $deliveryEan;
250
251
    /**
252
     * @var string
253
     */
254
    protected $shippingMethod;
255
256
    /**
257
     * @var int
258
     */
259
    protected $shippingMethodId;
260
261
    /**
262
     * @var Money
263
     */
264
    protected $shippingFee;
265
266
    /**
267
     * @var string
268
     */
269
    protected $paymentMethod;
270
271
    /**
272
     * @var int
273
     */
274
    protected $paymentMethodId;
275
276
    /**
277
     * @var Money
278
     */
279
    protected $paymentFee;
280
281
    /**
282
     * @var string
283
     */
284
    protected $loadBalancerRealIp;
285
286
    /**
287
     * @var string
288
     */
289
    protected $referrer;
290
291
    /**
292
     * @var PaymentLine[]
293
     */
294
    protected $paymentLines;
295
296 15
    public function __construct()
297
    {
298 15
        $this->paymentLines = [];
299 15
    }
300
301 3
    public static function createFromRequest(ServerRequestInterface $request) : Payment
302
    {
303 3
        $body = $request->getParsedBody();
304 3
        $body = is_array($body) ? $body : [];
305
306 3
        $payment = new static();
307 3
        $currency = new Currency($body['APICurrencySymbol']);
308
309 3
        $payment->setApiKey($body['APIkey'] ?? '');
310 3
        $payment->setMerchant($body['APIMerchant'] ?? '');
311 3
        $payment->setOrderId($body['APIOrderID'] ?? 0);
312 3
        $payment->setSessionId($body['APISessionID'] ?? '');
313 3
        $payment->setCurrencySymbol($body['APICurrencySymbol'] ?? '');
314 3
        $payment->setTotalAmount(new Money(static::priceStringToInt($body['APITotalAmount'] ?? '0.00', 'APITotalAmount'), $currency));
315 3
        $payment->setCallBackUrl($body['APICallBackUrl'] ?? '');
316 3
        $payment->setFullCallBackOkUrl($body['APIFullCallBackOKUrl'] ?? '');
317 3
        $payment->setCallBackOkUrl($body['APICallBackOKUrl'] ?? '');
318 3
        $payment->setCallBackServerUrl($body['APICallBackServerUrl'] ?? '');
319 3
        $payment->setLanguageId(isset($body['APILanguageID']) ? (int) $body['APILanguageID'] : 0);
320 3
        $payment->setTestMode(isset($body['APITestMode']) && 'True' === $body['APITestMode']);
321 3
        $payment->setPaymentGatewayCurrencyCode(isset($body['APIPayGatewayCurrCode']) ? (int) $body['APIPayGatewayCurrCode'] : 0);
322 3
        $payment->setCardTypeId(isset($body['APICardTypeID']) ? (int) $body['APICardTypeID'] : 0);
323 3
        $payment->setCustomerRekvNr($body['APICRekvNr'] ?? '');
324 3
        $payment->setCustomerName($body['APICName'] ?? '');
325 3
        $payment->setCustomerCompany($body['APICCompany'] ?? '');
326 3
        $payment->setCustomerAddress($body['APICAddress'] ?? '');
327 3
        $payment->setCustomerAddress2($body['APICAddress2'] ?? '');
328 3
        $payment->setCustomerZipCode($body['APICZipCode'] ?? '');
329 3
        $payment->setCustomerCity($body['APICCity'] ?? '');
330 3
        $payment->setCustomerCountryId(isset($body['APICCountryID']) ? (int) $body['APICCountryID'] : 0);
331 3
        $payment->setCustomerCountry($body['APICCountry'] ?? '');
332 3
        $payment->setCustomerPhone($body['APICPhone'] ?? '');
333 3
        $payment->setCustomerFax($body['APICFax'] ?? '');
334 3
        $payment->setCustomerEmail($body['APICEmail'] ?? '');
335 3
        $payment->setCustomerNote($body['APICNote'] ?? '');
336 3
        $payment->setCustomerCvrnr($body['APICcvrnr'] ?? '');
337 3
        $payment->setCustomerCustTypeId(isset($body['APICCustTypeID']) ? (int) $body['APICCustTypeID'] : 0);
338 3
        $payment->setCustomerEan($body['APICEAN'] ?? '');
339 3
        $payment->setCustomerRes1($body['APICres1'] ?? '');
340 3
        $payment->setCustomerRes2($body['APICres2'] ?? '');
341 3
        $payment->setCustomerRes3($body['APICres3'] ?? '');
342 3
        $payment->setCustomerRes4($body['APICres4'] ?? '');
343 3
        $payment->setCustomerRes5($body['APICres5'] ?? '');
344 3
        $payment->setDeliveryName($body['APIDName'] ?? '');
345 3
        $payment->setDeliveryCompany($body['APIDCompany'] ?? '');
346 3
        $payment->setDeliveryAddress($body['APIDAddress'] ?? '');
347 3
        $payment->setDeliveryAddress2($body['APIDAddress2'] ?? '');
348 3
        $payment->setDeliveryZipCode($body['APIDZipCode'] ?? '');
349 3
        $payment->setDeliveryCity($body['APIDCity'] ?? '');
350 3
        $payment->setDeliveryCountryID(isset($body['APIDCountryID']) ? (int) $body['APIDCountryID'] : 0);
351 3
        $payment->setDeliveryCountry($body['APIDCountry'] ?? '');
352 3
        $payment->setDeliveryPhone($body['APIDPhone'] ?? '');
353 3
        $payment->setDeliveryFax($body['APIDFax'] ?? '');
354 3
        $payment->setDeliveryEmail($body['APIDEmail'] ?? '');
355 3
        $payment->setDeliveryEan($body['APIDean'] ?? '');
356 3
        $payment->setShippingMethod($body['APIShippingMethod'] ?? '');
357 3
        $payment->setShippingMethodId(isset($body['APIShippingMethodID']) ? (int)$body['APIShippingMethodID'] : 0);
358 3
        $payment->setShippingFee(new Money(static::priceStringToInt($body['APIShippingFee'] ?? '0.00', 'APIShippingFee'), $currency));
359 3
        $payment->setPaymentMethod($body['APIPayMethod'] ?? '');
360 3
        $payment->setPaymentMethodId(isset($body['APIPayMethodID']) ? (int)$body['APIPayMethodID'] : 0);
361 3
        $payment->setPaymentFee(new Money(static::priceStringToInt($body['APIPayFee'] ?? '0.00', 'APIPayFee'), $currency));
362 3
        $payment->setCustomerIp($body['APICIP'] ?? '');
363 3
        $payment->setLoadBalancerRealIp($body['APILoadBalancerRealIP'] ?? '');
364 3
        $payment->setReferrer($request->hasHeader('referer') ? $request->getHeaderLine('referer') : '');
365
366
        // populate order lines
367 3
        $i = 1;
368 3
        while (isset($body['APIBasketProdAmount'.$i])) {
369 3
            $qty = (int) $body['APIBasketProdAmount'.$i];
370 3
            $productNumber = $body['APIBasketProdNumber'.$i] ?? '';
371 3
            $name = $body['APIBasketProdName'.$i] ?? '';
372 3
            $price = new Money(static::priceStringToInt($body['APIBasketProdPrice'.$i] ?? '0.00', 'APIBasketProdPrice'.$i), $currency);
373 3
            $vat = isset($body['APIBasketProdVAT'.$i]) ? (int) $body['APIBasketProdVAT'.$i] : 0;
374
375 3
            $payment->addPaymentLine(static::createPaymentLine($productNumber, $name, $qty, $price, $vat));
376
377 3
            ++$i;
378
        }
379
380 3
        return $payment;
381
    }
382
383
    /**
384
     * Takes strings like
385
     * - 1.000,50
386
     * - 1,000.50
387
     * - 1000.50
388
     * - 1000,50.
389
     *
390
     * and returns 100050
391
     *
392
     * @param string $str
393
     * @param string $propertyPath
394
     *
395
     * @return int
396
     */
397 6
    public static function priceStringToInt(string $str, string $propertyPath = '') : int
398
    {
399 6
        $str = trim($str);
400
401
        // verify format of string
402 6
        if (!preg_match('/(\.|,)[0-9]{2}$/', $str)) {
403 3
            throw new \InvalidArgumentException(($propertyPath ? $propertyPath.' (value: "'.$str.'")' : $str).
404 3
                ' does not match the currency string format');
405
        }
406 6
        $str = preg_replace('/[^0-9]+/', '', $str);
407
408 6
        return intval($str);
409
    }
410
411 3
    public static function createPaymentLine(string $productNumber, string $name, int $quantity, Money $price, int $vat)
412
    {
413 3
        return new PaymentLine($productNumber, $name, $quantity, $price, $vat);
414
    }
415
416
    /**
417
     * @return string
418
     */
419 6
    public function getApiKey(): ?string
420
    {
421 6
        return $this->apiKey;
422
    }
423
424
    /**
425
     * @param string $apiKey
426
     *
427
     * @return Payment
428
     */
429 6
    public function setApiKey(string $apiKey): self
430
    {
431 6
        $this->apiKey = $apiKey;
432
433 6
        return $this;
434
    }
435
436
    /**
437
     * @return string
438
     */
439 3
    public function getMerchant(): ?string
440
    {
441 3
        return $this->merchant;
442
    }
443
444
    /**
445
     * @param string $merchant
446
     *
447
     * @return Payment
448
     */
449 3
    public function setMerchant(string $merchant): self
450
    {
451 3
        $this->merchant = $merchant;
452
453 3
        return $this;
454
    }
455
456
    /**
457
     * @return int
458
     */
459 9
    public function getOrderId(): ?int
460
    {
461 9
        return $this->orderId;
462
    }
463
464
    /**
465
     * @param int $orderId
466
     *
467
     * @return Payment
468
     */
469 9
    public function setOrderId(int $orderId): self
470
    {
471 9
        $this->orderId = $orderId;
472
473 9
        return $this;
474
    }
475
476
    /**
477
     * @return string
478
     */
479 3
    public function getSessionId(): ?string
480
    {
481 3
        return $this->sessionId;
482
    }
483
484
    /**
485
     * @param string $sessionId
486
     *
487
     * @return Payment
488
     */
489 3
    public function setSessionId(string $sessionId): self
490
    {
491 3
        $this->sessionId = $sessionId;
492
493 3
        return $this;
494
    }
495
496
    /**
497
     * @return string
498
     */
499 3
    public function getCurrencySymbol(): ?string
500
    {
501 3
        return $this->currencySymbol;
502
    }
503
504
    /**
505
     * @param string $currencySymbol
506
     *
507
     * @return Payment
508
     */
509 3
    public function setCurrencySymbol(string $currencySymbol): self
510
    {
511 3
        $this->currencySymbol = $currencySymbol;
512
513 3
        return $this;
514
    }
515
516
    /**
517
     * @return Money
518
     */
519 6
    public function getTotalAmount(): ?Money
520
    {
521 6
        return $this->totalAmount;
522
    }
523
524
    /**
525
     * @param Money $totalAmount
526
     *
527
     * @return Payment
528
     */
529 6
    public function setTotalAmount(Money $totalAmount): self
530
    {
531 6
        $this->totalAmount = $totalAmount;
532
533 6
        return $this;
534
    }
535
536
    /**
537
     * @return string
538
     */
539 3
    public function getCallBackUrl(): ?string
540
    {
541 3
        return $this->callBackUrl;
542
    }
543
544
    /**
545
     * @param string $callBackUrl
546
     *
547
     * @return Payment
548
     */
549 3
    public function setCallBackUrl(string $callBackUrl): self
550
    {
551 3
        $this->callBackUrl = $callBackUrl;
552
553 3
        return $this;
554
    }
555
556
    /**
557
     * @return string
558
     */
559 3
    public function getFullCallBackOkUrl(): ?string
560
    {
561 3
        return $this->fullCallBackOkUrl;
562
    }
563
564
    /**
565
     * @param string $fullCallBackOkUrl
566
     *
567
     * @return Payment
568
     */
569 3
    public function setFullCallBackOkUrl(string $fullCallBackOkUrl): self
570
    {
571 3
        $this->fullCallBackOkUrl = $fullCallBackOkUrl;
572
573 3
        return $this;
574
    }
575
576
    /**
577
     * @return string
578
     */
579 3
    public function getCallBackOkUrl(): ?string
580
    {
581 3
        return $this->callBackOkUrl;
582
    }
583
584
    /**
585
     * @param string $callBackOkUrl
586
     *
587
     * @return Payment
588
     */
589 3
    public function setCallBackOkUrl(string $callBackOkUrl): self
590
    {
591 3
        $this->callBackOkUrl = $callBackOkUrl;
592
593 3
        return $this;
594
    }
595
596
    /**
597
     * @return string
598
     */
599 3
    public function getCallBackServerUrl(): ?string
600
    {
601 3
        return $this->callBackServerUrl;
602
    }
603
604
    /**
605
     * @param string $callBackServerUrl
606
     *
607
     * @return Payment
608
     */
609 3
    public function setCallBackServerUrl(string $callBackServerUrl): self
610
    {
611 3
        $this->callBackServerUrl = $callBackServerUrl;
612
613 3
        return $this;
614
    }
615
616
    /**
617
     * @return int
618
     */
619 3
    public function getLanguageId(): ?int
620
    {
621 3
        return $this->languageId;
622
    }
623
624
    /**
625
     * @param int $languageId
626
     *
627
     * @return Payment
628
     */
629 3
    public function setLanguageId(int $languageId): self
630
    {
631 3
        $this->languageId = $languageId;
632
633 3
        return $this;
634
    }
635
636
    /**
637
     * @return bool
638
     */
639 3
    public function isTestMode(): ?bool
640
    {
641 3
        return $this->testMode;
642
    }
643
644
    /**
645
     * @param bool $testMode
646
     *
647
     * @return Payment
648
     */
649 3
    public function setTestMode(bool $testMode): self
650
    {
651 3
        $this->testMode = $testMode;
652
653 3
        return $this;
654
    }
655
656
    /**
657
     * @return int
658
     */
659 9
    public function getPaymentGatewayCurrencyCode()
660
    {
661 9
        return $this->paymentGatewayCurrencyCode;
662
    }
663
664
    /**
665
     * @param int $paymentGatewayCurrencyCode
666
     *
667
     * @return Payment
668
     */
669 9
    public function setPaymentGatewayCurrencyCode(int $paymentGatewayCurrencyCode): self
670
    {
671 9
        $this->paymentGatewayCurrencyCode = $paymentGatewayCurrencyCode;
672
673 9
        return $this;
674
    }
675
676
    /**
677
     * @return int
678
     */
679 3
    public function getCardTypeId()
680
    {
681 3
        return $this->cardTypeId;
682
    }
683
684
    /**
685
     * @param int $cardTypeId
686
     *
687
     * @return Payment
688
     */
689 3
    public function setCardTypeId(int $cardTypeId): self
690
    {
691 3
        $this->cardTypeId = $cardTypeId;
692
693 3
        return $this;
694
    }
695
696
    /**
697
     * @return string
698
     */
699 3
    public function getCustomerRekvNr(): ?string
700
    {
701 3
        return $this->customerRekvNr;
702
    }
703
704
    /**
705
     * @param string $customerRekvNr
706
     *
707
     * @return Payment
708
     */
709 3
    public function setCustomerRekvNr(string $customerRekvNr): self
710
    {
711 3
        $this->customerRekvNr = $customerRekvNr;
712
713 3
        return $this;
714
    }
715
716
    /**
717
     * @return string
718
     */
719 3
    public function getCustomerName(): ?string
720
    {
721 3
        return $this->customerName;
722
    }
723
724
    /**
725
     * @param string $customerName
726
     *
727
     * @return Payment
728
     */
729 3
    public function setCustomerName(string $customerName): self
730
    {
731 3
        $this->customerName = $customerName;
732
733 3
        return $this;
734
    }
735
736
    /**
737
     * @return string
738
     */
739 3
    public function getCustomerCompany(): ?string
740
    {
741 3
        return $this->customerCompany;
742
    }
743
744
    /**
745
     * @param string $customerCompany
746
     *
747
     * @return Payment
748
     */
749 3
    public function setCustomerCompany(string $customerCompany): self
750
    {
751 3
        $this->customerCompany = $customerCompany;
752
753 3
        return $this;
754
    }
755
756
    /**
757
     * @return string
758
     */
759 3
    public function getCustomerAddress(): ?string
760
    {
761 3
        return $this->customerAddress;
762
    }
763
764
    /**
765
     * @param string $customerAddress
766
     *
767
     * @return Payment
768
     */
769 3
    public function setCustomerAddress(string $customerAddress): self
770
    {
771 3
        $this->customerAddress = $customerAddress;
772
773 3
        return $this;
774
    }
775
776
    /**
777
     * @return string
778
     */
779 3
    public function getCustomerAddress2(): ?string
780
    {
781 3
        return $this->customerAddress2;
782
    }
783
784
    /**
785
     * @param string $customerAddress2
786
     *
787
     * @return Payment
788
     */
789 3
    public function setCustomerAddress2(string $customerAddress2): self
790
    {
791 3
        $this->customerAddress2 = $customerAddress2;
792
793 3
        return $this;
794
    }
795
796
    /**
797
     * @return string
798
     */
799 3
    public function getCustomerZipCode(): ?string
800
    {
801 3
        return $this->customerZipCode;
802
    }
803
804
    /**
805
     * @param string $customerZipCode
806
     *
807
     * @return Payment
808
     */
809 3
    public function setCustomerZipCode(string $customerZipCode): self
810
    {
811 3
        $this->customerZipCode = $customerZipCode;
812
813 3
        return $this;
814
    }
815
816
    /**
817
     * @return string
818
     */
819 3
    public function getCustomerCity(): ?string
820
    {
821 3
        return $this->customerCity;
822
    }
823
824
    /**
825
     * @param string $customerCity
826
     *
827
     * @return Payment
828
     */
829 3
    public function setCustomerCity(string $customerCity): self
830
    {
831 3
        $this->customerCity = $customerCity;
832
833 3
        return $this;
834
    }
835
836
    /**
837
     * @return int
838
     */
839 3
    public function getCustomerCountryId()
840
    {
841 3
        return $this->customerCountryId;
842
    }
843
844
    /**
845
     * @param int $customerCountryId
846
     *
847
     * @return Payment
848
     */
849 3
    public function setCustomerCountryId(int $customerCountryId): self
850
    {
851 3
        $this->customerCountryId = $customerCountryId;
852
853 3
        return $this;
854
    }
855
856
    /**
857
     * @return string
858
     */
859 3
    public function getCustomerCountry(): ?string
860
    {
861 3
        return $this->customerCountry;
862
    }
863
864
    /**
865
     * @param string $customerCountry
866
     *
867
     * @return Payment
868
     */
869 3
    public function setCustomerCountry(string $customerCountry): self
870
    {
871 3
        $this->customerCountry = $customerCountry;
872
873 3
        return $this;
874
    }
875
876
    /**
877
     * @return string
878
     */
879 3
    public function getCustomerPhone(): ?string
880
    {
881 3
        return $this->customerPhone;
882
    }
883
884
    /**
885
     * @param string $customerPhone
886
     *
887
     * @return Payment
888
     */
889 3
    public function setCustomerPhone(string $customerPhone): self
890
    {
891 3
        $this->customerPhone = $customerPhone;
892
893 3
        return $this;
894
    }
895
896
    /**
897
     * @return string
898
     */
899 3
    public function getCustomerFax(): ?string
900
    {
901 3
        return $this->customerFax;
902
    }
903
904
    /**
905
     * @param string $customerFax
906
     *
907
     * @return Payment
908
     */
909 3
    public function setCustomerFax(string $customerFax): self
910
    {
911 3
        $this->customerFax = $customerFax;
912
913 3
        return $this;
914
    }
915
916
    /**
917
     * @return string
918
     */
919 3
    public function getCustomerEmail(): ?string
920
    {
921 3
        return $this->customerEmail;
922
    }
923
924
    /**
925
     * @param string $customerEmail
926
     *
927
     * @return Payment
928
     */
929 3
    public function setCustomerEmail(string $customerEmail): self
930
    {
931 3
        $this->customerEmail = $customerEmail;
932
933 3
        return $this;
934
    }
935
936
    /**
937
     * @return string
938
     */
939 3
    public function getCustomerNote(): ?string
940
    {
941 3
        return $this->customerNote;
942
    }
943
944
    /**
945
     * @param string $customerNote
946
     *
947
     * @return Payment
948
     */
949 3
    public function setCustomerNote(string $customerNote): self
950
    {
951 3
        $this->customerNote = $customerNote;
952
953 3
        return $this;
954
    }
955
956
    /**
957
     * @return string
958
     */
959 3
    public function getCustomerCvrnr(): ?string
960
    {
961 3
        return $this->customerCvrnr;
962
    }
963
964
    /**
965
     * @param string $customerCvrnr
966
     *
967
     * @return Payment
968
     */
969 3
    public function setCustomerCvrnr(string $customerCvrnr): self
970
    {
971 3
        $this->customerCvrnr = $customerCvrnr;
972
973 3
        return $this;
974
    }
975
976
    /**
977
     * @return int
978
     */
979 3
    public function getCustomerCustTypeId(): ?int
980
    {
981 3
        return $this->customerCustTypeId;
982
    }
983
984
    /**
985
     * @param int $customerCustTypeId
986
     *
987
     * @return Payment
988
     */
989 3
    public function setCustomerCustTypeId(int $customerCustTypeId): self
990
    {
991 3
        $this->customerCustTypeId = $customerCustTypeId;
992
993 3
        return $this;
994
    }
995
996
    /**
997
     * @return string
998
     */
999 3
    public function getCustomerEan(): ?string
1000
    {
1001 3
        return $this->customerEan;
1002
    }
1003
1004
    /**
1005
     * @param string $customerEan
1006
     *
1007
     * @return Payment
1008
     */
1009 3
    public function setCustomerEan(string $customerEan): self
1010
    {
1011 3
        $this->customerEan = $customerEan;
1012
1013 3
        return $this;
1014
    }
1015
1016
    /**
1017
     * @return string
1018
     */
1019 3
    public function getCustomerRes1(): ?string
1020
    {
1021 3
        return $this->customerRes1;
1022
    }
1023
1024
    /**
1025
     * @param string $customerRes1
1026
     *
1027
     * @return Payment
1028
     */
1029 3
    public function setCustomerRes1(string $customerRes1): self
1030
    {
1031 3
        $this->customerRes1 = $customerRes1;
1032
1033 3
        return $this;
1034
    }
1035
1036
    /**
1037
     * @return string
1038
     */
1039 3
    public function getCustomerRes2(): ?string
1040
    {
1041 3
        return $this->customerRes2;
1042
    }
1043
1044
    /**
1045
     * @param string $customerRes2
1046
     *
1047
     * @return Payment
1048
     */
1049 3
    public function setCustomerRes2(string $customerRes2): self
1050
    {
1051 3
        $this->customerRes2 = $customerRes2;
1052
1053 3
        return $this;
1054
    }
1055
1056
    /**
1057
     * @return string
1058
     */
1059 3
    public function getCustomerRes3(): ?string
1060
    {
1061 3
        return $this->customerRes3;
1062
    }
1063
1064
    /**
1065
     * @param string $customerRes3
1066
     *
1067
     * @return Payment
1068
     */
1069 3
    public function setCustomerRes3(string $customerRes3): self
1070
    {
1071 3
        $this->customerRes3 = $customerRes3;
1072
1073 3
        return $this;
1074
    }
1075
1076
    /**
1077
     * @return string
1078
     */
1079 3
    public function getCustomerRes4(): ?string
1080
    {
1081 3
        return $this->customerRes4;
1082
    }
1083
1084
    /**
1085
     * @param string $customerRes4
1086
     *
1087
     * @return Payment
1088
     */
1089 3
    public function setCustomerRes4(string $customerRes4): self
1090
    {
1091 3
        $this->customerRes4 = $customerRes4;
1092
1093 3
        return $this;
1094
    }
1095
1096
    /**
1097
     * @return string
1098
     */
1099 3
    public function getCustomerRes5(): ?string
1100
    {
1101 3
        return $this->customerRes5;
1102
    }
1103
1104
    /**
1105
     * @param string $customerRes5
1106
     *
1107
     * @return Payment
1108
     */
1109 3
    public function setCustomerRes5(string $customerRes5): self
1110
    {
1111 3
        $this->customerRes5 = $customerRes5;
1112
1113 3
        return $this;
1114
    }
1115
1116
    /**
1117
     * @return string
1118
     */
1119 3
    public function getCustomerIp(): ?string
1120
    {
1121 3
        return $this->customerIp;
1122
    }
1123
1124
    /**
1125
     * @param string $customerIp
1126
     *
1127
     * @return Payment
1128
     */
1129 3
    public function setCustomerIp(string $customerIp): self
1130
    {
1131 3
        $this->customerIp = $customerIp;
1132
1133 3
        return $this;
1134
    }
1135
1136
    /**
1137
     * @return string
1138
     */
1139 3
    public function getDeliveryName(): ?string
1140
    {
1141 3
        return $this->deliveryName;
1142
    }
1143
1144
    /**
1145
     * @param string $deliveryName
1146
     *
1147
     * @return Payment
1148
     */
1149 3
    public function setDeliveryName(string $deliveryName): self
1150
    {
1151 3
        $this->deliveryName = $deliveryName;
1152
1153 3
        return $this;
1154
    }
1155
1156
    /**
1157
     * @return string
1158
     */
1159 3
    public function getDeliveryCompany(): ?string
1160
    {
1161 3
        return $this->deliveryCompany;
1162
    }
1163
1164
    /**
1165
     * @param string $deliveryCompany
1166
     *
1167
     * @return Payment
1168
     */
1169 3
    public function setDeliveryCompany(string $deliveryCompany): self
1170
    {
1171 3
        $this->deliveryCompany = $deliveryCompany;
1172
1173 3
        return $this;
1174
    }
1175
1176
    /**
1177
     * @return string
1178
     */
1179 3
    public function getDeliveryAddress(): ?string
1180
    {
1181 3
        return $this->deliveryAddress;
1182
    }
1183
1184
    /**
1185
     * @param string $deliveryAddress
1186
     *
1187
     * @return Payment
1188
     */
1189 3
    public function setDeliveryAddress(string $deliveryAddress): self
1190
    {
1191 3
        $this->deliveryAddress = $deliveryAddress;
1192
1193 3
        return $this;
1194
    }
1195
1196
    /**
1197
     * @return string
1198
     */
1199 3
    public function getDeliveryAddress2(): ?string
1200
    {
1201 3
        return $this->deliveryAddress2;
1202
    }
1203
1204
    /**
1205
     * @param string $deliveryAddress2
1206
     *
1207
     * @return Payment
1208
     */
1209 3
    public function setDeliveryAddress2(string $deliveryAddress2): self
1210
    {
1211 3
        $this->deliveryAddress2 = $deliveryAddress2;
1212
1213 3
        return $this;
1214
    }
1215
1216
    /**
1217
     * @return string
1218
     */
1219 3
    public function getDeliveryZipCode(): ?string
1220
    {
1221 3
        return $this->deliveryZipCode;
1222
    }
1223
1224
    /**
1225
     * @param string $deliveryZipCode
1226
     *
1227
     * @return Payment
1228
     */
1229 3
    public function setDeliveryZipCode(string $deliveryZipCode): self
1230
    {
1231 3
        $this->deliveryZipCode = $deliveryZipCode;
1232
1233 3
        return $this;
1234
    }
1235
1236
    /**
1237
     * @return string
1238
     */
1239 3
    public function getDeliveryCity(): ?string
1240
    {
1241 3
        return $this->deliveryCity;
1242
    }
1243
1244
    /**
1245
     * @param string $deliveryCity
1246
     *
1247
     * @return Payment
1248
     */
1249 3
    public function setDeliveryCity(string $deliveryCity): self
1250
    {
1251 3
        $this->deliveryCity = $deliveryCity;
1252
1253 3
        return $this;
1254
    }
1255
1256
    /**
1257
     * @return int
1258
     */
1259 3
    public function getDeliveryCountryID()
1260
    {
1261 3
        return $this->deliveryCountryID;
1262
    }
1263
1264
    /**
1265
     * @param int $deliveryCountryID
1266
     *
1267
     * @return Payment
1268
     */
1269 3
    public function setDeliveryCountryID(int $deliveryCountryID): self
1270
    {
1271 3
        $this->deliveryCountryID = $deliveryCountryID;
1272
1273 3
        return $this;
1274
    }
1275
1276
    /**
1277
     * @return string
1278
     */
1279 3
    public function getDeliveryCountry(): ?string
1280
    {
1281 3
        return $this->deliveryCountry;
1282
    }
1283
1284
    /**
1285
     * @param string $deliveryCountry
1286
     *
1287
     * @return Payment
1288
     */
1289 3
    public function setDeliveryCountry(string $deliveryCountry): self
1290
    {
1291 3
        $this->deliveryCountry = $deliveryCountry;
1292
1293 3
        return $this;
1294
    }
1295
1296
    /**
1297
     * @return string
1298
     */
1299 3
    public function getDeliveryPhone(): ?string
1300
    {
1301 3
        return $this->deliveryPhone;
1302
    }
1303
1304
    /**
1305
     * @param string $deliveryPhone
1306
     *
1307
     * @return Payment
1308
     */
1309 3
    public function setDeliveryPhone(string $deliveryPhone): self
1310
    {
1311 3
        $this->deliveryPhone = $deliveryPhone;
1312
1313 3
        return $this;
1314
    }
1315
1316
    /**
1317
     * @return string
1318
     */
1319 3
    public function getDeliveryFax(): ?string
1320
    {
1321 3
        return $this->deliveryFax;
1322
    }
1323
1324
    /**
1325
     * @param string $deliveryFax
1326
     *
1327
     * @return Payment
1328
     */
1329 3
    public function setDeliveryFax(string $deliveryFax): self
1330
    {
1331 3
        $this->deliveryFax = $deliveryFax;
1332
1333 3
        return $this;
1334
    }
1335
1336
    /**
1337
     * @return string
1338
     */
1339 3
    public function getDeliveryEmail(): ?string
1340
    {
1341 3
        return $this->deliveryEmail;
1342
    }
1343
1344
    /**
1345
     * @param string $deliveryEmail
1346
     *
1347
     * @return Payment
1348
     */
1349 3
    public function setDeliveryEmail(string $deliveryEmail): self
1350
    {
1351 3
        $this->deliveryEmail = $deliveryEmail;
1352
1353 3
        return $this;
1354
    }
1355
1356
    /**
1357
     * @return string
1358
     */
1359 3
    public function getDeliveryEan(): ?string
1360
    {
1361 3
        return $this->deliveryEan;
1362
    }
1363
1364
    /**
1365
     * @param string $deliveryEan
1366
     *
1367
     * @return Payment
1368
     */
1369 3
    public function setDeliveryEan(string $deliveryEan): self
1370
    {
1371 3
        $this->deliveryEan = $deliveryEan;
1372
1373 3
        return $this;
1374
    }
1375
1376
    /**
1377
     * @return string
1378
     */
1379 3
    public function getShippingMethod(): ?string
1380
    {
1381 3
        return $this->shippingMethod;
1382
    }
1383
1384
    /**
1385
     * @param string $shippingMethod
1386
     *
1387
     * @return Payment
1388
     */
1389 3
    public function setShippingMethod(string $shippingMethod): self
1390
    {
1391 3
        $this->shippingMethod = $shippingMethod;
1392
1393 3
        return $this;
1394
    }
1395
1396
    /**
1397
     * @return int
1398
     */
1399 3
    public function getShippingMethodId(): ?int
1400
    {
1401 3
        return $this->shippingMethodId;
1402
    }
1403
1404
    /**
1405
     * @param int $shippingMethodId
1406
     * @return Payment
1407
     */
1408 3
    public function setShippingMethodId(int $shippingMethodId) : self
1409
    {
1410 3
        $this->shippingMethodId = $shippingMethodId;
1411 3
        return $this;
1412
    }
1413
1414
    /**
1415
     * @return Money
1416
     */
1417 3
    public function getShippingFee(): ?Money
1418
    {
1419 3
        return $this->shippingFee;
1420
    }
1421
1422
    /**
1423
     * @param Money $shippingFee
1424
     *
1425
     * @return Payment
1426
     */
1427 3
    public function setShippingFee(Money $shippingFee): self
1428
    {
1429 3
        $this->shippingFee = $shippingFee;
1430
1431 3
        return $this;
1432
    }
1433
1434
    /**
1435
     * @return string
1436
     */
1437 3
    public function getPaymentMethod(): ?string
1438
    {
1439 3
        return $this->paymentMethod;
1440
    }
1441
1442
    /**
1443
     * @param string $paymentMethod
1444
     *
1445
     * @return Payment
1446
     */
1447 3
    public function setPaymentMethod(string $paymentMethod): self
1448
    {
1449 3
        $this->paymentMethod = $paymentMethod;
1450
1451 3
        return $this;
1452
    }
1453
1454
    /**
1455
     * @return int
1456
     */
1457 3
    public function getPaymentMethodId(): ?int
1458
    {
1459 3
        return $this->paymentMethodId;
1460
    }
1461
1462
    /**
1463
     * @param int $paymentMethodId
1464
     * @return Payment
1465
     */
1466 3
    public function setPaymentMethodId(int $paymentMethodId) : self
1467
    {
1468 3
        $this->paymentMethodId = $paymentMethodId;
1469 3
        return $this;
1470
    }
1471
1472
    /**
1473
     * @return Money
1474
     */
1475 3
    public function getPaymentFee(): ?Money
1476
    {
1477 3
        return $this->paymentFee;
1478
    }
1479
1480
    /**
1481
     * @param Money $paymentFee
1482
     *
1483
     * @return Payment
1484
     */
1485 3
    public function setPaymentFee(Money $paymentFee): self
1486
    {
1487 3
        $this->paymentFee = $paymentFee;
1488
1489 3
        return $this;
1490
    }
1491
1492
    /**
1493
     * @return string
1494
     */
1495 3
    public function getLoadBalancerRealIp(): ?string
1496
    {
1497 3
        return $this->loadBalancerRealIp;
1498
    }
1499
1500
    /**
1501
     * @param string $loadBalancerRealIp
1502
     *
1503
     * @return Payment
1504
     */
1505 3
    public function setLoadBalancerRealIp(string $loadBalancerRealIp): self
1506
    {
1507 3
        $this->loadBalancerRealIp = $loadBalancerRealIp;
1508
1509 3
        return $this;
1510
    }
1511
1512
    /**
1513
     * @return string
1514
     */
1515 3
    public function getReferrer(): ?string
1516
    {
1517 3
        return $this->referrer;
1518
    }
1519
1520
    /**
1521
     * @param string $referrer
1522
     *
1523
     * @return Payment
1524
     */
1525 3
    public function setReferrer(string $referrer): self
1526
    {
1527 3
        $this->referrer = $referrer;
1528
1529 3
        return $this;
1530
    }
1531
1532
    /**
1533
     * @return PaymentLine[]|iterable
1534
     */
1535 6
    public function getPaymentLines(): iterable
1536
    {
1537 6
        return $this->paymentLines;
1538
    }
1539
1540
    /**
1541
     * @param PaymentLine[]|iterable $paymentLines
1542
     *
1543
     * @return Payment
1544
     */
1545 3
    public function setPaymentLines(iterable $paymentLines): self
1546
    {
1547 3
        $this->paymentLines = $paymentLines;
0 ignored issues
show
Documentation Bug introduced by
It seems like $paymentLines can also be of type object<Loevgaard\Dandomain\Pay\Model\iterable>. However, the property $paymentLines is declared as type array<integer,object<Loe...Pay\Model\PaymentLine>>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
1548
1549 3
        return $this;
1550
    }
1551
1552
    /**
1553
     * @param PaymentLine $paymentLine
1554
     *
1555
     * @return Payment
1556
     */
1557 3
    public function addPaymentLine(PaymentLine $paymentLine): self
1558
    {
1559 3
        $paymentLine->setPayment($this);
1560 3
        $this->paymentLines[] = $paymentLine;
1561
1562 3
        return $this;
1563
    }
1564
}
1565