Completed
Push — master ( 4dda3a...c96309 )
by Joachim
01:44
created

Payment::setCustomerRes5()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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