EventData::toArray()   F
last analyzed

Complexity

Conditions 29
Paths > 20000

Size

Total Lines 90
Code Lines 59

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 870

Importance

Changes 0
Metric Value
dl 0
loc 90
ccs 0
cts 89
cp 0
rs 2.0585
c 0
b 0
f 0
cc 29
eloc 59
nc 268435456
nop 0
crap 870

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Billogram\Model\Invoice;
6
7
use Billogram\Model\CreatableFromArray;
8
9
/**
10
 * @author Ibrahim Hizeoui <[email protected]>
11
 */
12
class EventData implements CreatableFromArray
13
{
14
    /**
15
     * @var string
16
     */
17
    private $invoiceNo;
18
19
    /**
20
     * @var string
21
     */
22
    private $deliveryMethod;
23
24
    /**
25
     * @var string
26
     */
27
    private $letterId;
28
29
    /**
30
     * @var int
31
     */
32
    private $amount;
33
34
    /**
35
     * @var string
36
     */
37
    private $payerName;
38
39
    /**
40
     * @var array
41
     */
42
    private $paymentFlags = [];
43
44
    /**
45
     * @var int
46
     */
47
    private $bankingAmount;
48
49
    /**
50
     * @var bool
51
     */
52
    private $manual;
53
54
    /**
55
     * @var int
56
     */
57
    private $reminderFee;
58
59
    /**
60
     * @var int
61
     */
62
    private $reminderCount;
63
64
    /**
65
     * @var int
66
     */
67
    private $interestRate;
68
69
    /**
70
     * @var string
71
     */
72
    private $customerEmail;
73
74
    /**
75
     * @var string
76
     */
77
    private $customerPhone;
78
79
    /**
80
     * @var string
81
     */
82
    private $ip;
83
84
    /**
85
     * @var string
86
     */
87
    private $type;
88
89
    /**
90
     * @var string[]
91
     */
92
    private $message;
93
94
    /**
95
     * @var string
96
     */
97
    private $fullStatus;
98
99
    /**
100
     * @var string
101
     */
102
    private $collectorMethod;
103
104
    /**
105
     * @var string
106
     */
107
    private $collectorReference;
108
109
    /**
110
     * @var string
111
     */
112
    private $factoringMethod;
113
114
    /**
115
     * @var string
116
     */
117
    private $factoringReference;
118
119
    /**
120
     * @var int
121
     */
122
    private $sellsFor;
123
124
    /**
125
     * @var int
126
     */
127
    private $soldFor;
128
129
    /**
130
     * @var string
131
     */
132
    private $bankgiro;
133
134
    /**
135
     * @var string
136
     */
137
    private $recipientIdentifier;
138
139
    /**
140
     * @var string
141
     */
142
    private $errorStatus;
143
144
    /**
145
     * @var int
146
     */
147
    private $totalSum;
148
149
    /**
150
     * @var int
151
     */
152
    private $remainingSum;
153
154
    /**
155
     * @var bool
156
     */
157
    private $scanningCentral;
158
159
    /**
160
     * @return string
161
     */
162
    public function getInvoiceNo(): string
163
    {
164
        return $this->invoiceNo;
165
    }
166
167
    /**
168
     * @param string $invoiceNo
169
     *
170
     * @return EventData
171
     */
172
    public function withInvoiceNo(string $invoiceNo)
173
    {
174
        $new = clone $this;
175
        $new->invoiceNo = $invoiceNo;
176
177
        return $new;
178
    }
179
180
    /**
181
     * @return string
182
     */
183
    public function getDeliveryMethod(): string
184
    {
185
        return $this->deliveryMethod;
186
    }
187
188
    /**
189
     * @param string $deliveryMethod
190
     *
191
     * @return EventData
192
     */
193
    public function withDeliveryMethod(string $deliveryMethod)
194
    {
195
        $new = clone $this;
196
        $new->deliveryMethod = $deliveryMethod;
197
198
        return $new;
199
    }
200
201
    /**
202
     * @return string
203
     */
204
    public function getLetterId(): string
205
    {
206
        return $this->letterId;
207
    }
208
209
    /**
210
     * @param string $letterId
211
     *
212
     * @return EventData
213
     */
214
    public function withLetterId(string $letterId)
215
    {
216
        $new = clone $this;
217
        $new->letterId = $letterId;
218
219
        return $new;
220
    }
221
222
    /**
223
     * @return int
224
     */
225
    public function getAmount(): int
226
    {
227
        return $this->amount;
228
    }
229
230
    /**
231
     * @param int $amount
232
     *
233
     * @return EventData
234
     */
235
    public function withAmount(int $amount)
236
    {
237
        $new = clone $this;
238
        $new->amount = $amount;
239
240
        return $new;
241
    }
242
243
    /**
244
     * @return string
245
     */
246
    public function getPayerName(): string
247
    {
248
        return $this->payerName;
249
    }
250
251
    /**
252
     * @param string $payerName
253
     *
254
     * @return EventData
255
     */
256
    public function withPayerName(string $payerName)
257
    {
258
        $new = clone $this;
259
        $new->payerName = $payerName;
260
261
        return $new;
262
    }
263
264
    /**
265
     * @return array
266
     */
267
    public function getPaymentFlags(): array
268
    {
269
        return $this->paymentFlags;
270
    }
271
272
    /**
273
     * @param array $paymentFlags
274
     *
275
     * @return EventData
276
     */
277
    public function withPaymentFlags(array $paymentFlags)
278
    {
279
        $new = clone $this;
280
        $new->paymentFlags = $paymentFlags;
281
282
        return $new;
283
    }
284
285
    /**
286
     * @return int
287
     */
288
    public function getBankingAmount(): int
289
    {
290
        return $this->bankingAmount;
291
    }
292
293
    /**
294
     * @param int $bankingAmount
295
     *
296
     * @return EventData
297
     */
298
    public function withBankingAmount(int $bankingAmount)
299
    {
300
        $new = clone $this;
301
        $new->bankingAmount = $bankingAmount;
302
303
        return $new;
304
    }
305
306
    /**
307
     * @return bool
308
     */
309
    public function isManual(): bool
310
    {
311
        return $this->manual;
312
    }
313
314
    /**
315
     * @param bool $manual
316
     *
317
     * @return EventData
318
     */
319
    public function withManual(bool $manual)
320
    {
321
        $new = clone $this;
322
        $new->manual = $manual;
323
324
        return $new;
325
    }
326
327
    /**
328
     * @return int
329
     */
330
    public function getReminderFee(): int
331
    {
332
        return $this->reminderFee;
333
    }
334
335
    /**
336
     * @param int $reminderFee
337
     *
338
     * @return EventData
339
     */
340
    public function withReminderFee(int $reminderFee)
341
    {
342
        $new = clone $this;
343
        $new->reminderFee = $reminderFee;
344
345
        return $new;
346
    }
347
348
    /**
349
     * @return int
350
     */
351
    public function getReminderCount(): int
352
    {
353
        return $this->reminderCount;
354
    }
355
356
    /**
357
     * @param int $reminderCount
358
     *
359
     * @return EventData
360
     */
361
    public function withReminderCount(int $reminderCount)
362
    {
363
        $new = clone $this;
364
        $new->reminderCount = $reminderCount;
365
366
        return $new;
367
    }
368
369
    /**
370
     * @return int
371
     */
372
    public function getInterestRate(): int
373
    {
374
        return $this->interestRate;
375
    }
376
377
    /**
378
     * @param int $interestRate
379
     *
380
     * @return EventData
381
     */
382
    public function withInterestRate(int $interestRate)
383
    {
384
        $new = clone $this;
385
        $new->interestRate = $interestRate;
386
387
        return $new;
388
    }
389
390
    /**
391
     * @return string
392
     */
393
    public function getCustomerEmail(): string
394
    {
395
        return $this->customerEmail;
396
    }
397
398
    /**
399
     * @param string $customerEmail
400
     *
401
     * @return EventData
402
     */
403
    public function withCustomerEmail(string $customerEmail)
404
    {
405
        $new = clone $this;
406
        $new->customerEmail = $customerEmail;
407
408
        return $new;
409
    }
410
411
    /**
412
     * @return string
413
     */
414
    public function getCustomerPhone(): string
415
    {
416
        return $this->customerPhone;
417
    }
418
419
    /**
420
     * @param string $customerPhone
421
     *
422
     * @return EventData
423
     */
424
    public function withCustomerPhone(string $customerPhone)
425
    {
426
        $new = clone $this;
427
        $new->customerPhone = $customerPhone;
428
429
        return $new;
430
    }
431
432
    /**
433
     * @return string
434
     */
435
    public function getIp(): string
436
    {
437
        return $this->ip;
438
    }
439
440
    /**
441
     * @param string $ip
442
     *
443
     * @return EventData
444
     */
445
    public function withIp(string $ip)
446
    {
447
        $new = clone $this;
448
        $new->ip = $ip;
449
450
        return $new;
451
    }
452
453
    /**
454
     * @return string
455
     */
456
    public function getType(): string
457
    {
458
        return $this->type;
459
    }
460
461
    /**
462
     * @param string $type
463
     *
464
     * @return EventData
465
     */
466
    public function withType(string $type)
467
    {
468
        $new = clone $this;
469
        $new->type = $type;
470
471
        return $new;
472
    }
473
474
    /**
475
     * @return \string[]
476
     */
477
    public function getMessage(): array
478
    {
479
        return $this->message;
480
    }
481
482
    /**
483
     * @param \string[] $message
484
     *
485
     * @return EventData
486
     */
487
    public function withMessage(array $message)
488
    {
489
        $new = clone $this;
490
        $new->message = $message;
0 ignored issues
show
Documentation Bug introduced by Ibrahimhizeoui
It seems like $message of type array<integer,object<string>> is incompatible with the declared type array<integer,string> of property $message.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
491
492
        return $new;
493
    }
494
495
    /**
496
     * @return string
497
     */
498
    public function getFullStatus(): string
499
    {
500
        return $this->fullStatus;
501
    }
502
503
    /**
504
     * @param string $fullStatus
505
     *
506
     * @return EventData
507
     */
508
    public function withFullStatus(string $fullStatus)
509
    {
510
        $new = clone $this;
511
        $new->fullStatus = $fullStatus;
512
513
        return $new;
514
    }
515
516
    /**
517
     * @return string
518
     */
519
    public function getCollectorMethod(): string
520
    {
521
        return $this->collectorMethod;
522
    }
523
524
    /**
525
     * @param string $collectorMethod
526
     *
527
     * @return EventData
528
     */
529
    public function setCollectorMethod(string $collectorMethod)
530
    {
531
        $new = clone $this;
532
        $new->collectorMethod = $collectorMethod;
533
534
        return $new;
535
    }
536
537
    /**
538
     * @return string
539
     */
540
    public function getCollectorReference(): string
541
    {
542
        return $this->collectorReference;
543
    }
544
545
    /**
546
     * @param string $collectorReference
547
     *
548
     * @return EventData
549
     */
550
    public function withCollectorReference(string $collectorReference)
551
    {
552
        $new = clone $this;
553
        $new->collectorReference = $collectorReference;
554
555
        return $new;
556
    }
557
558
    /**
559
     * @return string
560
     */
561
    public function getFactoringMethod(): string
562
    {
563
        return $this->factoringMethod;
564
    }
565
566
    /**
567
     * @param string $factoringMethod
568
     *
569
     * @return EventData
570
     */
571
    public function withFactoringMethod(string $factoringMethod)
572
    {
573
        $new = clone $this;
574
        $new->factoringMethod = $factoringMethod;
575
576
        return $new;
577
    }
578
579
    /**
580
     * @return string
581
     */
582
    public function getFactoringReference(): string
583
    {
584
        return $this->factoringReference;
585
    }
586
587
    /**
588
     * @param string $factoringReference
589
     *
590
     * @return EventData
591
     */
592
    public function withFactoringReference(string $factoringReference)
593
    {
594
        $new = clone $this;
595
        $new->factoringReference = $factoringReference;
596
597
        return $new;
598
    }
599
600
    /**
601
     * @return int
602
     */
603
    public function getSellsFor(): int
604
    {
605
        return $this->sellsFor;
606
    }
607
608
    /**
609
     * @param int $sellsFor
610
     *
611
     * @return EventData
612
     */
613
    public function withSellsFor(int $sellsFor)
614
    {
615
        $new = clone $this;
616
        $new->sellsFor = $sellsFor;
617
618
        return $new;
619
    }
620
621
    /**
622
     * @return int
623
     */
624
    public function getSoldFor(): int
625
    {
626
        return $this->soldFor;
627
    }
628
629
    /**
630
     * @param int $soldFor
631
     *
632
     * @return EventData
633
     */
634
    public function withSoldFor(int $soldFor)
635
    {
636
        $new = clone $this;
637
        $new->soldFor = $soldFor;
638
639
        return $new;
640
    }
641
642
    /**
643
     * @return string
644
     */
645
    public function getBankgiro(): string
646
    {
647
        return $this->bankgiro;
648
    }
649
650
    /**
651
     * @param string $bankgiro
652
     *
653
     * @return EventData
654
     */
655
    public function withBankgiro(string $bankgiro)
656
    {
657
        $new = clone $this;
658
        $new->bankgiro = $bankgiro;
659
660
        return $new;
661
    }
662
663
    /**
664
     * @return string
665
     */
666
    public function getRecipientIdentifier(): string
667
    {
668
        return $this->recipientIdentifier;
669
    }
670
671
    /**
672
     * @param string $recipientIdentifier
673
     *
674
     * @return EventData
675
     */
676
    public function withRecipientIdentifier(string $recipientIdentifier)
677
    {
678
        $new = clone $this;
679
        $new->recipientIdentifier = $recipientIdentifier;
680
681
        return $new;
682
    }
683
684
    /**
685
     * @return string
686
     */
687
    public function getErrorStatus(): string
688
    {
689
        return $this->errorStatus;
690
    }
691
692
    /**
693
     * @param string $errorStatus
694
     *
695
     * @return EventData
696
     */
697
    public function withErrorStatus(string $errorStatus)
698
    {
699
        $new = clone $this;
700
        $new->errorStatus = $errorStatus;
701
702
        return $new;
703
    }
704
705
    /**
706
     * @return int
707
     */
708
    public function getTotalSum(): int
709
    {
710
        return $this->totalSum;
711
    }
712
713
    /**
714
     * @param int $totalSum
715
     *
716
     * @return EventData
717
     */
718
    public function withTotalSum(int $totalSum)
719
    {
720
        $new = clone $this;
721
        $new->totalSum = $totalSum;
722
723
        return $new;
724
    }
725
726
    /**
727
     * @return int
728
     */
729
    public function getRemainingSum(): int
730
    {
731
        return $this->remainingSum;
732
    }
733
734
    /**
735
     * @param int $remainingSum
736
     *
737
     * @return EventData
738
     */
739
    public function withRemainingSum(int $remainingSum)
740
    {
741
        $new = clone $this;
742
        $new->remainingSum = $remainingSum;
743
744
        return $new;
745
    }
746
747
    /**
748
     * @return mixed
749
     */
750
    public function getScanningCentral()
751
    {
752
        return $this->scanningCentral;
753
    }
754
755
    /**
756
     * @param bool $scanningCentral
757
     *
758
     * @return EventData
759
     */
760
    public function withScanningCentral(bool $scanningCentral)
761
    {
762
        $new = clone $this;
763
        $new->scanningCentral = $scanningCentral;
764
765
        return $new;
766
    }
767
768
    public function toArray()
769
    {
770
        $data = [];
771
        if (null !== $this->invoiceNo) {
772
            $data['invoice_no'] = $this->invoiceNo;
773
        }
774
        if (null !== $this->deliveryMethod) {
775
            $data['delivery_method'] = $this->deliveryMethod;
776
        }
777
        if (null !== $this->letterId) {
778
            $data['letter_id'] = $this->letterId;
779
        }
780
        if (null !== $this->amount) {
781
            $data['amount'] = $this->amount;
782
        }
783
        if (null !== $this->paymentFlags) {
784
            $data['payment_flags'] = $this->paymentFlags;
785
        }
786
        if (null !== $this->bankingAmount) {
787
            $data['banking_amount'] = $this->bankingAmount;
788
        }
789
        if (null !== $this->manual) {
790
            $data['manual'] = $this->manual;
791
        }
792
        if (null !== $this->reminderFee) {
793
            $data['reminder_fee'] = $this->reminderFee;
794
        }
795
        if (null !== $this->reminderCount) {
796
            $data['reminder_count'] = $this->reminderCount;
797
        }
798
        if (null !== $this->interestRate) {
799
            $data['interest_rate'] = $this->interestRate;
800
        }
801
        if (null !== $this->customerPhone) {
802
            $data['customer_phone'] = $this->customerPhone;
803
        }
804
        if (null !== $this->customerEmail) {
805
            $data['customer_email'] = $this->customerEmail;
806
        }
807
        if (null !== $this->ip) {
808
            $data['ip'] = $this->ip;
809
        }
810
        if (null !== $this->type) {
811
            $data['type'] = $this->type;
812
        }
813
        if (null !== $this->message) {
814
            $data['message'] = $this->message;
815
        }
816
        if (null !== $this->fullStatus) {
817
            $data['full_status'] = $this->fullStatus;
818
        }
819
        if (null !== $this->collectorMethod) {
820
            $data['collector_method'] = $this->collectorMethod;
821
        }
822
        if (null !== $this->collectorReference) {
823
            $data['collector_reference'] = $this->collectorReference;
824
        }
825
        if (null !== $this->factoringMethod) {
826
            $data['factoring_method'] = $this->factoringMethod;
827
        }
828
        if (null !== $this->factoringReference) {
829
            $data['factoring_reference'] = $this->factoringReference;
830
        }
831
        if (null !== $this->sellsFor) {
832
            $data['sells_for'] = $this->sellsFor;
833
        }
834
        if (null !== $this->soldFor) {
835
            $data['sold_for'] = $this->soldFor;
836
        }
837
        if (null !== $this->bankgiro) {
838
            $data['bankgiro'] = $this->bankgiro;
839
        }
840
        if (null !== $this->recipientIdentifier) {
841
            $data['recipient_identifier'] = $this->recipientIdentifier;
842
        }
843
        if (null !== $this->errorStatus) {
844
            $data['error_status'] = $this->errorStatus;
845
        }
846
        if (null !== $this->totalSum) {
847
            $data['total_sum'] = $this->totalSum;
848
        }
849
        if (null !== $this->remainingSum) {
850
            $data['remaining_sum'] = $this->remainingSum;
851
        }
852
        if (null !== $this->scanningCentral) {
853
            $data['scanning_central'] = $this->scanningCentral;
854
        }
855
856
        return $data;
857
    }
858
859
    /**
860
     * Create an API response object from the HTTP response from the API server.
861
     *
862
     * @param array $data
863
     *
864
     * @return self
865
     */
866
    public static function createFromArray(array $data = null)
867
    {
868
        $eventData = new self();
869
        $eventData->invoiceNo = $data['invoice_no'] ?? null;
870
        $eventData->deliveryMethod = $data['delivery_method'] ?? null;
871
        $eventData->letterId = $data['letter_id'] ?? null;
872
        $eventData->amount = $data['amount'] ?? null;
873
        $eventData->payerName = $data['payer_name'] ?? null;
874
        $eventData->paymentFlags = $data['payment_flags'] ?? null;
875
        $eventData->bankingAmount = $data['banking_amount'] ?? null;
876
        $eventData->manual = $data['manual'] ?? null;
877
        $eventData->reminderFee = $data['reminder_fee'] ?? null;
878
        $eventData->reminderCount = $data['reminder_count'] ?? null;
879
        $eventData->interestRate = $data['interest_rate'] ?? null;
880
        $eventData->customerPhone = $data['customer_phone'] ?? null;
881
        $eventData->ip = $data['ip'] ?? null;
882
        $eventData->type = $data['type'] ?? null;
883
        $eventData->message = $data['message'] ?? [];
884
        $eventData->fullStatus = $data['full_status'] ?? null;
885
        $eventData->collectorMethod = $data['collector_method'] ?? null;
886
        $eventData->collectorReference = $data['collector_reference'] ?? null;
887
        $eventData->factoringMethod = $data['factoring_method'] ?? null;
888
        $eventData->factoringReference = $data['factoring_reference'] ?? null;
889
        $eventData->sellsFor = $data['sells_for'] ?? null;
890
        $eventData->soldFor = $data['sold_for'] ?? null;
891
        $eventData->bankgiro = $data['bankgiro'] ?? null;
892
        $eventData->recipientIdentifier = $data['recipient_identifier'] ?? null;
893
        $eventData->errorStatus = $data['error_status'] ?? null;
894
        $eventData->totalSum = $data['total_sum'] ?? null;
895
        $eventData->remainingSum = $data['remaining_sum'] ?? null;
896
        $eventData->scanningCentral = $data['scanning_central'] ?? null;
897
898
        return $eventData;
899
    }
900
}
901