Completed
Push — master ( 219a86...6a68ad )
by Joachim
12:18
created

PaymentRequest::setDeliveryAddress()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

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