Completed
Push — master ( 60e823...86baa2 )
by Joachim
03:52
created

Payment::priceStringToInt()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 2
nop 2
crap 3
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(new PaymentLine($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
    /**
412
     * @return string
413
     */
414 6
    public function getApiKey(): ?string
415
    {
416 6
        return $this->apiKey;
417
    }
418
419
    /**
420
     * @param string $apiKey
421
     *
422
     * @return Payment
423
     */
424 6
    public function setApiKey(string $apiKey): self
425
    {
426 6
        $this->apiKey = $apiKey;
427
428 6
        return $this;
429
    }
430
431
    /**
432
     * @return string
433
     */
434 3
    public function getMerchant(): ?string
435
    {
436 3
        return $this->merchant;
437
    }
438
439
    /**
440
     * @param string $merchant
441
     *
442
     * @return Payment
443
     */
444 3
    public function setMerchant(string $merchant): self
445
    {
446 3
        $this->merchant = $merchant;
447
448 3
        return $this;
449
    }
450
451
    /**
452
     * @return int
453
     */
454 9
    public function getOrderId(): ?int
455
    {
456 9
        return $this->orderId;
457
    }
458
459
    /**
460
     * @param int $orderId
461
     *
462
     * @return Payment
463
     */
464 9
    public function setOrderId(int $orderId): self
465
    {
466 9
        $this->orderId = $orderId;
467
468 9
        return $this;
469
    }
470
471
    /**
472
     * @return string
473
     */
474 3
    public function getSessionId(): ?string
475
    {
476 3
        return $this->sessionId;
477
    }
478
479
    /**
480
     * @param string $sessionId
481
     *
482
     * @return Payment
483
     */
484 3
    public function setSessionId(string $sessionId): self
485
    {
486 3
        $this->sessionId = $sessionId;
487
488 3
        return $this;
489
    }
490
491
    /**
492
     * @return string
493
     */
494 3
    public function getCurrencySymbol(): ?string
495
    {
496 3
        return $this->currencySymbol;
497
    }
498
499
    /**
500
     * @param string $currencySymbol
501
     *
502
     * @return Payment
503
     */
504 3
    public function setCurrencySymbol(string $currencySymbol): self
505
    {
506 3
        $this->currencySymbol = $currencySymbol;
507
508 3
        return $this;
509
    }
510
511
    /**
512
     * @return Money
513
     */
514 6
    public function getTotalAmount(): ?Money
515
    {
516 6
        return $this->totalAmount;
517
    }
518
519
    /**
520
     * @param Money $totalAmount
521
     *
522
     * @return Payment
523
     */
524 6
    public function setTotalAmount(Money $totalAmount): self
525
    {
526 6
        $this->totalAmount = $totalAmount;
527
528 6
        return $this;
529
    }
530
531
    /**
532
     * @return string
533
     */
534 3
    public function getCallBackUrl(): ?string
535
    {
536 3
        return $this->callBackUrl;
537
    }
538
539
    /**
540
     * @param string $callBackUrl
541
     *
542
     * @return Payment
543
     */
544 3
    public function setCallBackUrl(string $callBackUrl): self
545
    {
546 3
        $this->callBackUrl = $callBackUrl;
547
548 3
        return $this;
549
    }
550
551
    /**
552
     * @return string
553
     */
554 3
    public function getFullCallBackOkUrl(): ?string
555
    {
556 3
        return $this->fullCallBackOkUrl;
557
    }
558
559
    /**
560
     * @param string $fullCallBackOkUrl
561
     *
562
     * @return Payment
563
     */
564 3
    public function setFullCallBackOkUrl(string $fullCallBackOkUrl): self
565
    {
566 3
        $this->fullCallBackOkUrl = $fullCallBackOkUrl;
567
568 3
        return $this;
569
    }
570
571
    /**
572
     * @return string
573
     */
574 3
    public function getCallBackOkUrl(): ?string
575
    {
576 3
        return $this->callBackOkUrl;
577
    }
578
579
    /**
580
     * @param string $callBackOkUrl
581
     *
582
     * @return Payment
583
     */
584 3
    public function setCallBackOkUrl(string $callBackOkUrl): self
585
    {
586 3
        $this->callBackOkUrl = $callBackOkUrl;
587
588 3
        return $this;
589
    }
590
591
    /**
592
     * @return string
593
     */
594 3
    public function getCallBackServerUrl(): ?string
595
    {
596 3
        return $this->callBackServerUrl;
597
    }
598
599
    /**
600
     * @param string $callBackServerUrl
601
     *
602
     * @return Payment
603
     */
604 3
    public function setCallBackServerUrl(string $callBackServerUrl): self
605
    {
606 3
        $this->callBackServerUrl = $callBackServerUrl;
607
608 3
        return $this;
609
    }
610
611
    /**
612
     * @return int
613
     */
614 3
    public function getLanguageId(): ?int
615
    {
616 3
        return $this->languageId;
617
    }
618
619
    /**
620
     * @param int $languageId
621
     *
622
     * @return Payment
623
     */
624 3
    public function setLanguageId(int $languageId): self
625
    {
626 3
        $this->languageId = $languageId;
627
628 3
        return $this;
629
    }
630
631
    /**
632
     * @return bool
633
     */
634 3
    public function isTestMode(): ?bool
635
    {
636 3
        return $this->testMode;
637
    }
638
639
    /**
640
     * @param bool $testMode
641
     *
642
     * @return Payment
643
     */
644 3
    public function setTestMode(bool $testMode): self
645
    {
646 3
        $this->testMode = $testMode;
647
648 3
        return $this;
649
    }
650
651
    /**
652
     * @return int
653
     */
654 9
    public function getPaymentGatewayCurrencyCode()
655
    {
656 9
        return $this->paymentGatewayCurrencyCode;
657
    }
658
659
    /**
660
     * @param int $paymentGatewayCurrencyCode
661
     *
662
     * @return Payment
663
     */
664 9
    public function setPaymentGatewayCurrencyCode(int $paymentGatewayCurrencyCode): self
665
    {
666 9
        $this->paymentGatewayCurrencyCode = $paymentGatewayCurrencyCode;
667
668 9
        return $this;
669
    }
670
671
    /**
672
     * @return int
673
     */
674 3
    public function getCardTypeId()
675
    {
676 3
        return $this->cardTypeId;
677
    }
678
679
    /**
680
     * @param int $cardTypeId
681
     *
682
     * @return Payment
683
     */
684 3
    public function setCardTypeId(int $cardTypeId): self
685
    {
686 3
        $this->cardTypeId = $cardTypeId;
687
688 3
        return $this;
689
    }
690
691
    /**
692
     * @return string
693
     */
694 3
    public function getCustomerRekvNr(): ?string
695
    {
696 3
        return $this->customerRekvNr;
697
    }
698
699
    /**
700
     * @param string $customerRekvNr
701
     *
702
     * @return Payment
703
     */
704 3
    public function setCustomerRekvNr(string $customerRekvNr): self
705
    {
706 3
        $this->customerRekvNr = $customerRekvNr;
707
708 3
        return $this;
709
    }
710
711
    /**
712
     * @return string
713
     */
714 3
    public function getCustomerName(): ?string
715
    {
716 3
        return $this->customerName;
717
    }
718
719
    /**
720
     * @param string $customerName
721
     *
722
     * @return Payment
723
     */
724 3
    public function setCustomerName(string $customerName): self
725
    {
726 3
        $this->customerName = $customerName;
727
728 3
        return $this;
729
    }
730
731
    /**
732
     * @return string
733
     */
734 3
    public function getCustomerCompany(): ?string
735
    {
736 3
        return $this->customerCompany;
737
    }
738
739
    /**
740
     * @param string $customerCompany
741
     *
742
     * @return Payment
743
     */
744 3
    public function setCustomerCompany(string $customerCompany): self
745
    {
746 3
        $this->customerCompany = $customerCompany;
747
748 3
        return $this;
749
    }
750
751
    /**
752
     * @return string
753
     */
754 3
    public function getCustomerAddress(): ?string
755
    {
756 3
        return $this->customerAddress;
757
    }
758
759
    /**
760
     * @param string $customerAddress
761
     *
762
     * @return Payment
763
     */
764 3
    public function setCustomerAddress(string $customerAddress): self
765
    {
766 3
        $this->customerAddress = $customerAddress;
767
768 3
        return $this;
769
    }
770
771
    /**
772
     * @return string
773
     */
774 3
    public function getCustomerAddress2(): ?string
775
    {
776 3
        return $this->customerAddress2;
777
    }
778
779
    /**
780
     * @param string $customerAddress2
781
     *
782
     * @return Payment
783
     */
784 3
    public function setCustomerAddress2(string $customerAddress2): self
785
    {
786 3
        $this->customerAddress2 = $customerAddress2;
787
788 3
        return $this;
789
    }
790
791
    /**
792
     * @return string
793
     */
794 3
    public function getCustomerZipCode(): ?string
795
    {
796 3
        return $this->customerZipCode;
797
    }
798
799
    /**
800
     * @param string $customerZipCode
801
     *
802
     * @return Payment
803
     */
804 3
    public function setCustomerZipCode(string $customerZipCode): self
805
    {
806 3
        $this->customerZipCode = $customerZipCode;
807
808 3
        return $this;
809
    }
810
811
    /**
812
     * @return string
813
     */
814 3
    public function getCustomerCity(): ?string
815
    {
816 3
        return $this->customerCity;
817
    }
818
819
    /**
820
     * @param string $customerCity
821
     *
822
     * @return Payment
823
     */
824 3
    public function setCustomerCity(string $customerCity): self
825
    {
826 3
        $this->customerCity = $customerCity;
827
828 3
        return $this;
829
    }
830
831
    /**
832
     * @return int
833
     */
834 3
    public function getCustomerCountryId()
835
    {
836 3
        return $this->customerCountryId;
837
    }
838
839
    /**
840
     * @param int $customerCountryId
841
     *
842
     * @return Payment
843
     */
844 3
    public function setCustomerCountryId(int $customerCountryId): self
845
    {
846 3
        $this->customerCountryId = $customerCountryId;
847
848 3
        return $this;
849
    }
850
851
    /**
852
     * @return string
853
     */
854 3
    public function getCustomerCountry(): ?string
855
    {
856 3
        return $this->customerCountry;
857
    }
858
859
    /**
860
     * @param string $customerCountry
861
     *
862
     * @return Payment
863
     */
864 3
    public function setCustomerCountry(string $customerCountry): self
865
    {
866 3
        $this->customerCountry = $customerCountry;
867
868 3
        return $this;
869
    }
870
871
    /**
872
     * @return string
873
     */
874 3
    public function getCustomerPhone(): ?string
875
    {
876 3
        return $this->customerPhone;
877
    }
878
879
    /**
880
     * @param string $customerPhone
881
     *
882
     * @return Payment
883
     */
884 3
    public function setCustomerPhone(string $customerPhone): self
885
    {
886 3
        $this->customerPhone = $customerPhone;
887
888 3
        return $this;
889
    }
890
891
    /**
892
     * @return string
893
     */
894 3
    public function getCustomerFax(): ?string
895
    {
896 3
        return $this->customerFax;
897
    }
898
899
    /**
900
     * @param string $customerFax
901
     *
902
     * @return Payment
903
     */
904 3
    public function setCustomerFax(string $customerFax): self
905
    {
906 3
        $this->customerFax = $customerFax;
907
908 3
        return $this;
909
    }
910
911
    /**
912
     * @return string
913
     */
914 3
    public function getCustomerEmail(): ?string
915
    {
916 3
        return $this->customerEmail;
917
    }
918
919
    /**
920
     * @param string $customerEmail
921
     *
922
     * @return Payment
923
     */
924 3
    public function setCustomerEmail(string $customerEmail): self
925
    {
926 3
        $this->customerEmail = $customerEmail;
927
928 3
        return $this;
929
    }
930
931
    /**
932
     * @return string
933
     */
934 3
    public function getCustomerNote(): ?string
935
    {
936 3
        return $this->customerNote;
937
    }
938
939
    /**
940
     * @param string $customerNote
941
     *
942
     * @return Payment
943
     */
944 3
    public function setCustomerNote(string $customerNote): self
945
    {
946 3
        $this->customerNote = $customerNote;
947
948 3
        return $this;
949
    }
950
951
    /**
952
     * @return string
953
     */
954 3
    public function getCustomerCvrnr(): ?string
955
    {
956 3
        return $this->customerCvrnr;
957
    }
958
959
    /**
960
     * @param string $customerCvrnr
961
     *
962
     * @return Payment
963
     */
964 3
    public function setCustomerCvrnr(string $customerCvrnr): self
965
    {
966 3
        $this->customerCvrnr = $customerCvrnr;
967
968 3
        return $this;
969
    }
970
971
    /**
972
     * @return int
973
     */
974 3
    public function getCustomerCustTypeId(): ?int
975
    {
976 3
        return $this->customerCustTypeId;
977
    }
978
979
    /**
980
     * @param int $customerCustTypeId
981
     *
982
     * @return Payment
983
     */
984 3
    public function setCustomerCustTypeId(int $customerCustTypeId): self
985
    {
986 3
        $this->customerCustTypeId = $customerCustTypeId;
987
988 3
        return $this;
989
    }
990
991
    /**
992
     * @return string
993
     */
994 3
    public function getCustomerEan(): ?string
995
    {
996 3
        return $this->customerEan;
997
    }
998
999
    /**
1000
     * @param string $customerEan
1001
     *
1002
     * @return Payment
1003
     */
1004 3
    public function setCustomerEan(string $customerEan): self
1005
    {
1006 3
        $this->customerEan = $customerEan;
1007
1008 3
        return $this;
1009
    }
1010
1011
    /**
1012
     * @return string
1013
     */
1014 3
    public function getCustomerRes1(): ?string
1015
    {
1016 3
        return $this->customerRes1;
1017
    }
1018
1019
    /**
1020
     * @param string $customerRes1
1021
     *
1022
     * @return Payment
1023
     */
1024 3
    public function setCustomerRes1(string $customerRes1): self
1025
    {
1026 3
        $this->customerRes1 = $customerRes1;
1027
1028 3
        return $this;
1029
    }
1030
1031
    /**
1032
     * @return string
1033
     */
1034 3
    public function getCustomerRes2(): ?string
1035
    {
1036 3
        return $this->customerRes2;
1037
    }
1038
1039
    /**
1040
     * @param string $customerRes2
1041
     *
1042
     * @return Payment
1043
     */
1044 3
    public function setCustomerRes2(string $customerRes2): self
1045
    {
1046 3
        $this->customerRes2 = $customerRes2;
1047
1048 3
        return $this;
1049
    }
1050
1051
    /**
1052
     * @return string
1053
     */
1054 3
    public function getCustomerRes3(): ?string
1055
    {
1056 3
        return $this->customerRes3;
1057
    }
1058
1059
    /**
1060
     * @param string $customerRes3
1061
     *
1062
     * @return Payment
1063
     */
1064 3
    public function setCustomerRes3(string $customerRes3): self
1065
    {
1066 3
        $this->customerRes3 = $customerRes3;
1067
1068 3
        return $this;
1069
    }
1070
1071
    /**
1072
     * @return string
1073
     */
1074 3
    public function getCustomerRes4(): ?string
1075
    {
1076 3
        return $this->customerRes4;
1077
    }
1078
1079
    /**
1080
     * @param string $customerRes4
1081
     *
1082
     * @return Payment
1083
     */
1084 3
    public function setCustomerRes4(string $customerRes4): self
1085
    {
1086 3
        $this->customerRes4 = $customerRes4;
1087
1088 3
        return $this;
1089
    }
1090
1091
    /**
1092
     * @return string
1093
     */
1094 3
    public function getCustomerRes5(): ?string
1095
    {
1096 3
        return $this->customerRes5;
1097
    }
1098
1099
    /**
1100
     * @param string $customerRes5
1101
     *
1102
     * @return Payment
1103
     */
1104 3
    public function setCustomerRes5(string $customerRes5): self
1105
    {
1106 3
        $this->customerRes5 = $customerRes5;
1107
1108 3
        return $this;
1109
    }
1110
1111
    /**
1112
     * @return string
1113
     */
1114 3
    public function getCustomerIp(): ?string
1115
    {
1116 3
        return $this->customerIp;
1117
    }
1118
1119
    /**
1120
     * @param string $customerIp
1121
     *
1122
     * @return Payment
1123
     */
1124 3
    public function setCustomerIp(string $customerIp): self
1125
    {
1126 3
        $this->customerIp = $customerIp;
1127
1128 3
        return $this;
1129
    }
1130
1131
    /**
1132
     * @return string
1133
     */
1134 3
    public function getDeliveryName(): ?string
1135
    {
1136 3
        return $this->deliveryName;
1137
    }
1138
1139
    /**
1140
     * @param string $deliveryName
1141
     *
1142
     * @return Payment
1143
     */
1144 3
    public function setDeliveryName(string $deliveryName): self
1145
    {
1146 3
        $this->deliveryName = $deliveryName;
1147
1148 3
        return $this;
1149
    }
1150
1151
    /**
1152
     * @return string
1153
     */
1154 3
    public function getDeliveryCompany(): ?string
1155
    {
1156 3
        return $this->deliveryCompany;
1157
    }
1158
1159
    /**
1160
     * @param string $deliveryCompany
1161
     *
1162
     * @return Payment
1163
     */
1164 3
    public function setDeliveryCompany(string $deliveryCompany): self
1165
    {
1166 3
        $this->deliveryCompany = $deliveryCompany;
1167
1168 3
        return $this;
1169
    }
1170
1171
    /**
1172
     * @return string
1173
     */
1174 3
    public function getDeliveryAddress(): ?string
1175
    {
1176 3
        return $this->deliveryAddress;
1177
    }
1178
1179
    /**
1180
     * @param string $deliveryAddress
1181
     *
1182
     * @return Payment
1183
     */
1184 3
    public function setDeliveryAddress(string $deliveryAddress): self
1185
    {
1186 3
        $this->deliveryAddress = $deliveryAddress;
1187
1188 3
        return $this;
1189
    }
1190
1191
    /**
1192
     * @return string
1193
     */
1194 3
    public function getDeliveryAddress2(): ?string
1195
    {
1196 3
        return $this->deliveryAddress2;
1197
    }
1198
1199
    /**
1200
     * @param string $deliveryAddress2
1201
     *
1202
     * @return Payment
1203
     */
1204 3
    public function setDeliveryAddress2(string $deliveryAddress2): self
1205
    {
1206 3
        $this->deliveryAddress2 = $deliveryAddress2;
1207
1208 3
        return $this;
1209
    }
1210
1211
    /**
1212
     * @return string
1213
     */
1214 3
    public function getDeliveryZipCode(): ?string
1215
    {
1216 3
        return $this->deliveryZipCode;
1217
    }
1218
1219
    /**
1220
     * @param string $deliveryZipCode
1221
     *
1222
     * @return Payment
1223
     */
1224 3
    public function setDeliveryZipCode(string $deliveryZipCode): self
1225
    {
1226 3
        $this->deliveryZipCode = $deliveryZipCode;
1227
1228 3
        return $this;
1229
    }
1230
1231
    /**
1232
     * @return string
1233
     */
1234 3
    public function getDeliveryCity(): ?string
1235
    {
1236 3
        return $this->deliveryCity;
1237
    }
1238
1239
    /**
1240
     * @param string $deliveryCity
1241
     *
1242
     * @return Payment
1243
     */
1244 3
    public function setDeliveryCity(string $deliveryCity): self
1245
    {
1246 3
        $this->deliveryCity = $deliveryCity;
1247
1248 3
        return $this;
1249
    }
1250
1251
    /**
1252
     * @return int
1253
     */
1254 3
    public function getDeliveryCountryID()
1255
    {
1256 3
        return $this->deliveryCountryID;
1257
    }
1258
1259
    /**
1260
     * @param int $deliveryCountryID
1261
     *
1262
     * @return Payment
1263
     */
1264 3
    public function setDeliveryCountryID(int $deliveryCountryID): self
1265
    {
1266 3
        $this->deliveryCountryID = $deliveryCountryID;
1267
1268 3
        return $this;
1269
    }
1270
1271
    /**
1272
     * @return string
1273
     */
1274 3
    public function getDeliveryCountry(): ?string
1275
    {
1276 3
        return $this->deliveryCountry;
1277
    }
1278
1279
    /**
1280
     * @param string $deliveryCountry
1281
     *
1282
     * @return Payment
1283
     */
1284 3
    public function setDeliveryCountry(string $deliveryCountry): self
1285
    {
1286 3
        $this->deliveryCountry = $deliveryCountry;
1287
1288 3
        return $this;
1289
    }
1290
1291
    /**
1292
     * @return string
1293
     */
1294 3
    public function getDeliveryPhone(): ?string
1295
    {
1296 3
        return $this->deliveryPhone;
1297
    }
1298
1299
    /**
1300
     * @param string $deliveryPhone
1301
     *
1302
     * @return Payment
1303
     */
1304 3
    public function setDeliveryPhone(string $deliveryPhone): self
1305
    {
1306 3
        $this->deliveryPhone = $deliveryPhone;
1307
1308 3
        return $this;
1309
    }
1310
1311
    /**
1312
     * @return string
1313
     */
1314 3
    public function getDeliveryFax(): ?string
1315
    {
1316 3
        return $this->deliveryFax;
1317
    }
1318
1319
    /**
1320
     * @param string $deliveryFax
1321
     *
1322
     * @return Payment
1323
     */
1324 3
    public function setDeliveryFax(string $deliveryFax): self
1325
    {
1326 3
        $this->deliveryFax = $deliveryFax;
1327
1328 3
        return $this;
1329
    }
1330
1331
    /**
1332
     * @return string
1333
     */
1334 3
    public function getDeliveryEmail(): ?string
1335
    {
1336 3
        return $this->deliveryEmail;
1337
    }
1338
1339
    /**
1340
     * @param string $deliveryEmail
1341
     *
1342
     * @return Payment
1343
     */
1344 3
    public function setDeliveryEmail(string $deliveryEmail): self
1345
    {
1346 3
        $this->deliveryEmail = $deliveryEmail;
1347
1348 3
        return $this;
1349
    }
1350
1351
    /**
1352
     * @return string
1353
     */
1354 3
    public function getDeliveryEan(): ?string
1355
    {
1356 3
        return $this->deliveryEan;
1357
    }
1358
1359
    /**
1360
     * @param string $deliveryEan
1361
     *
1362
     * @return Payment
1363
     */
1364 3
    public function setDeliveryEan(string $deliveryEan): self
1365
    {
1366 3
        $this->deliveryEan = $deliveryEan;
1367
1368 3
        return $this;
1369
    }
1370
1371
    /**
1372
     * @return string
1373
     */
1374 3
    public function getShippingMethod(): ?string
1375
    {
1376 3
        return $this->shippingMethod;
1377
    }
1378
1379
    /**
1380
     * @param string $shippingMethod
1381
     *
1382
     * @return Payment
1383
     */
1384 3
    public function setShippingMethod(string $shippingMethod): self
1385
    {
1386 3
        $this->shippingMethod = $shippingMethod;
1387
1388 3
        return $this;
1389
    }
1390
1391
    /**
1392
     * @return int
1393
     */
1394 3
    public function getShippingMethodId(): ?int
1395
    {
1396 3
        return $this->shippingMethodId;
1397
    }
1398
1399
    /**
1400
     * @param int $shippingMethodId
1401
     * @return Payment
1402
     */
1403 3
    public function setShippingMethodId(int $shippingMethodId) : self
1404
    {
1405 3
        $this->shippingMethodId = $shippingMethodId;
1406 3
        return $this;
1407
    }
1408
1409
    /**
1410
     * @return Money
1411
     */
1412 3
    public function getShippingFee(): ?Money
1413
    {
1414 3
        return $this->shippingFee;
1415
    }
1416
1417
    /**
1418
     * @param Money $shippingFee
1419
     *
1420
     * @return Payment
1421
     */
1422 3
    public function setShippingFee(Money $shippingFee): self
1423
    {
1424 3
        $this->shippingFee = $shippingFee;
1425
1426 3
        return $this;
1427
    }
1428
1429
    /**
1430
     * @return string
1431
     */
1432 3
    public function getPaymentMethod(): ?string
1433
    {
1434 3
        return $this->paymentMethod;
1435
    }
1436
1437
    /**
1438
     * @param string $paymentMethod
1439
     *
1440
     * @return Payment
1441
     */
1442 3
    public function setPaymentMethod(string $paymentMethod): self
1443
    {
1444 3
        $this->paymentMethod = $paymentMethod;
1445
1446 3
        return $this;
1447
    }
1448
1449
    /**
1450
     * @return int
1451
     */
1452 3
    public function getPaymentMethodId(): ?int
1453
    {
1454 3
        return $this->paymentMethodId;
1455
    }
1456
1457
    /**
1458
     * @param int $paymentMethodId
1459
     * @return Payment
1460
     */
1461 3
    public function setPaymentMethodId(int $paymentMethodId) : self
1462
    {
1463 3
        $this->paymentMethodId = $paymentMethodId;
1464 3
        return $this;
1465
    }
1466
1467
    /**
1468
     * @return Money
1469
     */
1470 3
    public function getPaymentFee(): ?Money
1471
    {
1472 3
        return $this->paymentFee;
1473
    }
1474
1475
    /**
1476
     * @param Money $paymentFee
1477
     *
1478
     * @return Payment
1479
     */
1480 3
    public function setPaymentFee(Money $paymentFee): self
1481
    {
1482 3
        $this->paymentFee = $paymentFee;
1483
1484 3
        return $this;
1485
    }
1486
1487
    /**
1488
     * @return string
1489
     */
1490 3
    public function getLoadBalancerRealIp(): ?string
1491
    {
1492 3
        return $this->loadBalancerRealIp;
1493
    }
1494
1495
    /**
1496
     * @param string $loadBalancerRealIp
1497
     *
1498
     * @return Payment
1499
     */
1500 3
    public function setLoadBalancerRealIp(string $loadBalancerRealIp): self
1501
    {
1502 3
        $this->loadBalancerRealIp = $loadBalancerRealIp;
1503
1504 3
        return $this;
1505
    }
1506
1507
    /**
1508
     * @return string
1509
     */
1510 3
    public function getReferrer(): ?string
1511
    {
1512 3
        return $this->referrer;
1513
    }
1514
1515
    /**
1516
     * @param string $referrer
1517
     *
1518
     * @return Payment
1519
     */
1520 3
    public function setReferrer(string $referrer): self
1521
    {
1522 3
        $this->referrer = $referrer;
1523
1524 3
        return $this;
1525
    }
1526
1527
    /**
1528
     * @return PaymentLine[]|iterable
1529
     */
1530 6
    public function getPaymentLines(): iterable
1531
    {
1532 6
        return $this->paymentLines;
1533
    }
1534
1535
    /**
1536
     * @param PaymentLine[]|iterable $paymentLines
1537
     *
1538
     * @return Payment
1539
     */
1540 3
    public function setPaymentLines(iterable $paymentLines): self
1541
    {
1542 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...
1543
1544 3
        return $this;
1545
    }
1546
1547
    /**
1548
     * @param PaymentLine $paymentLine
1549
     *
1550
     * @return Payment
1551
     */
1552 3
    public function addPaymentLine(PaymentLine $paymentLine): self
1553
    {
1554 3
        $paymentLine->setPayment($this);
1555 3
        $this->paymentLines[] = $paymentLine;
1556
1557 3
        return $this;
1558
    }
1559
}
1560