Completed
Push — master ( 6d44f1...70e9d1 )
by Joachim
01:31
created

Payment::getFullCallBackOkUrl()   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 18
    public function __construct()
297
    {
298 18
        $this->paymentLines = [];
299 18
    }
300
    
301 6
    public static function createFromRequest(ServerRequestInterface $request) : Payment
302
    {
303 6
        $payment = new static();
304 6
        $payment->populateFromRequest($request);
305 6
        return $payment;
306
    }
307
308 6
    public function populateFromRequest(ServerRequestInterface $request)
309
    {
310 6
        $body = $request->getParsedBody();
311 6
        $body = is_array($body) ? $body : [];
312
313
        // set currency because we use it to create Money objects
314 6
        $this->setCurrencySymbol($body['APICurrencySymbol'] ?? '');
315
        
316 6
        $totalAmount = $this->createMoneyFromFloat($body['APITotalAmount'] ?? '0.00');
317 6
        if ($totalAmount) {
318 3
            $this->setTotalAmount($totalAmount);
319
        }
320
321 6
        $shippingFee = $this->createMoneyFromFloat($body['APIShippingFee'] ?? '0.00');
322 6
        if ($shippingFee) {
323 3
            $this->setShippingFee($shippingFee);
324
        }
325
326 6
        $paymentFee = $this->createMoneyFromFloat($body['APIPayFee'] ?? '0.00');
327 6
        if ($paymentFee) {
328 3
            $this->setPaymentFee($paymentFee);
329
        }
330
331 6
        $this->setApiKey($body['APIkey'] ?? '');
332 6
        $this->setMerchant($body['APIMerchant'] ?? '');
333 6
        $this->setOrderId($body['APIOrderID'] ?? 0);
334 6
        $this->setSessionId($body['APISessionID'] ?? '');
335 6
        $this->setCallBackUrl($body['APICallBackUrl'] ?? '');
336 6
        $this->setFullCallBackOkUrl($body['APIFullCallBackOKUrl'] ?? '');
337 6
        $this->setCallBackOkUrl($body['APICallBackOKUrl'] ?? '');
338 6
        $this->setCallBackServerUrl($body['APICallBackServerUrl'] ?? '');
339 6
        $this->setLanguageId((int)($body['APILanguageID'] ?? 0));
340 6
        $this->setTestMode(isset($body['APITestMode']) && 'True' === $body['APITestMode']);
341 6
        $this->setPaymentGatewayCurrencyCode((int)($body['APIPayGatewayCurrCode'] ??  0));
342 6
        $this->setCardTypeId((int)($body['APICardTypeID'] ?? 0));
343 6
        $this->setCustomerRekvNr($body['APICRekvNr'] ?? '');
344 6
        $this->setCustomerName($body['APICName'] ?? '');
345 6
        $this->setCustomerCompany($body['APICCompany'] ?? '');
346 6
        $this->setCustomerAddress($body['APICAddress'] ?? '');
347 6
        $this->setCustomerAddress2($body['APICAddress2'] ?? '');
348 6
        $this->setCustomerZipCode($body['APICZipCode'] ?? '');
349 6
        $this->setCustomerCity($body['APICCity'] ?? '');
350 6
        $this->setCustomerCountryId((int)($body['APICCountryID'] ?? 0));
351 6
        $this->setCustomerCountry($body['APICCountry'] ?? '');
352 6
        $this->setCustomerPhone($body['APICPhone'] ?? '');
353 6
        $this->setCustomerFax($body['APICFax'] ?? '');
354 6
        $this->setCustomerEmail($body['APICEmail'] ?? '');
355 6
        $this->setCustomerNote($body['APICNote'] ?? '');
356 6
        $this->setCustomerCvrnr($body['APICcvrnr'] ?? '');
357 6
        $this->setCustomerCustTypeId((int)($body['APICCustTypeID'] ?? 0));
358 6
        $this->setCustomerEan($body['APICEAN'] ?? '');
359 6
        $this->setCustomerRes1($body['APICres1'] ?? '');
360 6
        $this->setCustomerRes2($body['APICres2'] ?? '');
361 6
        $this->setCustomerRes3($body['APICres3'] ?? '');
362 6
        $this->setCustomerRes4($body['APICres4'] ?? '');
363 6
        $this->setCustomerRes5($body['APICres5'] ?? '');
364 6
        $this->setDeliveryName($body['APIDName'] ?? '');
365 6
        $this->setDeliveryCompany($body['APIDCompany'] ?? '');
366 6
        $this->setDeliveryAddress($body['APIDAddress'] ?? '');
367 6
        $this->setDeliveryAddress2($body['APIDAddress2'] ?? '');
368 6
        $this->setDeliveryZipCode($body['APIDZipCode'] ?? '');
369 6
        $this->setDeliveryCity($body['APIDCity'] ?? '');
370 6
        $this->setDeliveryCountryID((int)($body['APIDCountryID'] ?? 0));
371 6
        $this->setDeliveryCountry($body['APIDCountry'] ?? '');
372 6
        $this->setDeliveryPhone($body['APIDPhone'] ?? '');
373 6
        $this->setDeliveryFax($body['APIDFax'] ?? '');
374 6
        $this->setDeliveryEmail($body['APIDEmail'] ?? '');
375 6
        $this->setDeliveryEan($body['APIDean'] ?? '');
376 6
        $this->setShippingMethod($body['APIShippingMethod'] ?? '');
377 6
        $this->setShippingMethodId((int)($body['APIShippingMethodID'] ?? 0));
378 6
        $this->setPaymentMethod($body['APIPayMethod'] ?? '');
379 6
        $this->setPaymentMethodId((int)($body['APIPayMethodID'] ?? 0));
380 6
        $this->setCustomerIp($body['APICIP'] ?? '');
381 6
        $this->setLoadBalancerRealIp($body['APILoadBalancerRealIP'] ?? '');
382 6
        $this->setReferrer($request->hasHeader('referer') ? $request->getHeaderLine('referer') : '');
383
384
        // populate order lines
385 6
        $i = 1;
386 6
        while (isset($body['APIBasketProdAmount'.$i])) {
387 3
            $qty = (int)$body['APIBasketProdAmount'.$i];
388 3
            $productNumber = $body['APIBasketProdNumber'.$i] ?? '';
389 3
            $name = $body['APIBasketProdName'.$i] ?? '';
390 3
            $price = $this->createMoneyFromFloat($body['APIBasketProdPrice'.$i] ?? '0.00');
391 3
            $vat = (int)($body['APIBasketProdVAT'.$i] ?? 0);
392
393 3
            $this->addPaymentLine(static::createPaymentLine($productNumber, $name, $qty, $price, $vat));
0 ignored issues
show
Bug introduced by
It seems like $price defined by $this->createMoneyFromFl...Price' . $i] ?? '0.00') on line 390 can be null; however, Loevgaard\Dandomain\Pay\...nt::createPaymentLine() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

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

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
1600 3
            return null;
1601
        }
1602
1603 3
        return new Money($amount, new Currency($this->getCurrency()));
1604
    }
1605
1606
    /**
1607
     * A helper method for creating a Money object from a float based on the shared currency
1608
     *
1609
     * The float can be any format, i.e. 1.50 or 1,50
1610
     *
1611
     * @param string $amount
1612
     * @return Money|null
1613
     */
1614 6
    protected function createMoneyFromFloat(string $amount = '0.00') : ?Money
1615
    {
1616 6
        $amount = static::priceStringToInt((string)$amount);
1617 6
        return $this->createMoney($amount);
1618
    }
1619
}
1620