Invoice   F
last analyzed

Complexity

Total Complexity 84

Size/Duplication

Total Lines 674
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 35.7%

Importance

Changes 0
Metric Value
wmc 84
lcom 1
cbo 0
dl 0
loc 674
ccs 90
cts 252
cp 0.357
rs 1.926
c 0
b 0
f 0

84 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getUrl() 0 4 1
A getUrlTaxReductionList() 0 4 1
A getAddress1() 0 4 1
A getAddress2() 0 4 1
A getAdministrationFee() 0 4 1
A getAdministrationFeeVat() 0 4 1
A getBalance() 0 4 1
A getBasisTaxReduction() 0 4 1
A isBooked() 0 4 1
A isCancelled() 0 4 1
A getCity() 0 4 1
A getComments() 0 4 1
A getContractReference() 0 4 1
A getContributionPercent() 0 4 1
A getContributionValue() 0 4 1
A getCostCenter() 0 4 1
A getCountry() 0 4 1
A getCredit() 0 4 1
A getCreditInvoiceReference() 0 4 1
A getCurrency() 0 4 1
A getCurrencyRate() 0 4 1
A getCurrencyUnit() 0 4 1
A getCustomerName() 0 4 1
A getCustomerNumber() 0 4 1
A getDeliveryAddress1() 0 4 1
A getDeliveryAddress2() 0 4 1
A getDeliveryCity() 0 4 1
A getDeliveryCountry() 0 4 1
A getDeliveryDate() 0 4 1
A getDeliveryName() 0 4 1
A getDeliveryZipCode() 0 4 1
A getDocumentNumber() 0 4 1
A getDueDate() 0 4 1
B createFromArray() 0 90 1
A getEdiInformation() 0 4 1
A getEuQuarterlyReport() 0 4 1
A getEmailInformation() 0 4 1
A getExternalInvoiceReference1() 0 4 1
A getExternalInvoiceReference2() 0 4 1
A getFreight() 0 4 1
A getFreightVat() 0 4 1
A getGross() 0 4 1
A isHouseWork() 0 4 1
A getInvoiceDate() 0 4 1
A getInvoicePeriodEnd() 0 4 1
A getInvoicePeriodStart() 0 4 1
A getInvoiceReference() 0 4 1
A getInvoiceRows() 0 4 1
A getInvoiceType() 0 4 1
A getLabels() 0 4 1
A getLanguage() 0 4 1
A getLastRemindDate() 0 4 1
A getNet() 0 4 1
A getNotCompleted() 0 4 1
A getOcr() 0 4 1
A getOfferReference() 0 4 1
A getOrderReference() 0 4 1
A getOrganisationNumber() 0 4 1
A getOurReference() 0 4 1
A getPaymentWay() 0 4 1
A getPhone1() 0 4 1
A getPhone2() 0 4 1
A getPriceList() 0 4 1
A getPrintTemplate() 0 4 1
A getProject() 0 4 1
A getRemarks() 0 4 1
A getReminders() 0 4 1
A getRoundOff() 0 4 1
A isSent() 0 4 1
A getTaxReduction() 0 4 1
A getTermsOfDelivery() 0 4 1
A getTermsOfPayment() 0 4 1
A getTotal() 0 4 1
A getTotalToPay() 0 4 1
A getTotalVat() 0 4 1
A getVatIncluded() 0 4 1
A getVoucherNumber() 0 4 1
A getVoucherSeries() 0 4 1
A getVoucherYear() 0 4 1
A getWayOfDelivery() 0 4 1
A getYourOrderNumber() 0 4 1
A getYourReference() 0 4 1
A getZipCode() 0 4 1

How to fix   Complexity   

Complex Class

Complex classes like Invoice often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Invoice, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
declare(strict_types=1);
4
5
namespace FAPI\Fortnox\Model\Invoice;
6
7
use FAPI\Fortnox\Model\CreatableFromArray;
8
9
class Invoice implements CreatableFromArray
10
{
11
    /** @var string|null */
12
    private $url;
13
    /** @var string|null */
14
    private $urlTaxReductionList;
15
    /** @var string|null */
16
    private $address1;
17
    /** @var string|null */
18
    private $address2;
19
    /** @var int|null */
20
    private $administrationFee;
21
    /** @var int|null */
22
    private $administrationFeeVat;
23
    /** @var int|null */
24
    private $balance;
25
    /** @var int|null */
26
    private $basisTaxReduction;
27
    /** @var bool */
28
    private $booked;
29
    /** @var bool */
30
    private $cancelled;
31
    /** @var string|null */
32
    private $city;
33
    /** @var string|null */
34
    private $comments;
35
    /** @var int|null */
36
    private $contractReference;
37
    /** @var float|null */
38
    private $contributionPercent;
39
    /** @var int|null */
40
    private $contributionValue;
41
    /** @var string|null */
42
    private $costCenter;
43
    /** @var string|null */
44
    private $country;
45
    /**
46
     * @var string|null It looks like this is a boolean in a string.. "false".
47
     */
48
    private $credit;
49
    /** @var string|null */
50
    private $creditInvoiceReference;
51
    /** @var string|null */
52
    private $currency;
53
    /** @var int|null */
54
    private $currencyRate;
55
    /** @var int|null */
56
    private $currencyUnit;
57
    /** @var string|null */
58
    private $customerName;
59
    /** @var string|null */
60
    private $customerNumber;
61
    /** @var string|null */
62
    private $deliveryAddress1;
63
    /** @var string|null */
64
    private $deliveryAddress2;
65
    /** @var string|null */
66
    private $deliveryCity;
67
    /** @var string|null */
68
    private $deliveryCountry;
69
    /** @var string|null */
70
    private $deliveryDate;
71
    /** @var string|null */
72
    private $deliveryName;
73
    /** @var string|null */
74
    private $deliveryZipCode;
75
    /** @var string|null */
76
    private $documentNumber;
77
    /** @var string|null */
78
    private $dueDate;
79
    /** @var array */
80
    private $ediInformation;
81
    /** @var string|null */
82
    private $euQuarterlyReport;
83
    /** @var array */
84
    private $emailInformation;
85
    /** @var string|null */
86
    private $externalInvoiceReference1;
87
    /** @var string|null */
88
    private $externalInvoiceReference2;
89
    /** @var int|null */
90
    private $freight;
91
    /** @var float|null */
92
    private $freightVat;
93
    /** @var int|null */
94
    private $gross;
95
    /** @var bool */
96
    private $houseWork;
97
    /** @var string|null */
98
    private $invoiceDate;
99
    /** @var string|null */
100
    private $invoicePeriodEnd;
101
    /** @var string|null */
102
    private $invoicePeriodStart;
103
    /** @var string|null */
104
    private $invoiceReference;
105
    /** @var array */
106
    private $InvoiceRows;
107
    /** @var string|null */
108
    private $invoiceType;
109
    /** @var array */
110
    private $labels;
111
    /** @var string|null */
112
    private $language;
113
    /** @var string|null */
114
    private $lastRemindDate;
115
    /** @var string|null */
116
    private $net;
117
    /** @var bool|null */
118
    private $notCompleted;
119
    /** @var string|null */
120
    private $ocr;
121
    /** @var string|null */
122
    private $offerReference;
123
    /** @var string|null */
124
    private $orderReference;
125
    /** @var string|null */
126
    private $organisationNumber;
127
    /** @var string|null */
128
    private $ourReference;
129
    /** @var string|null */
130
    private $paymentWay;
131
    /** @var string|null */
132
    private $phone1;
133
    /** @var string|null */
134
    private $phone2;
135
    /** @var string|null */
136
    private $priceList;
137
    /** @var string|null */
138
    private $printTemplate;
139
    /** @var string|null */
140
    private $project;
141
    /** @var string|null */
142
    private $remarks;
143
    /** @var string|null */
144
    private $reminders;
145
    /** @var string|null */
146
    private $roundOff;
147
    /** @var bool */
148
    private $sent;
149
    /** @var string|null */
150
    private $taxReduction;
151
    /** @var string|null */
152
    private $termsOfDelivery;
153
    /** @var string|null */
154
    private $termsOfPayment;
155
    /** @var int|null */
156
    private $total;
157
    /** @var int|null */
158
    private $totalToPay;
159
    /** @var float|null */
160
    private $totalVat;
161
    /** @var bool|null */
162
    private $vatIncluded;
163
    /** @var string|null */
164
    private $voucherNumber;
165
    /** @var string|null */
166
    private $voucherSeries;
167
    /** @var string|null */
168
    private $voucherYear;
169
    /** @var string|null */
170
    private $wayOfDelivery;
171
    /** @var string|null */
172
    private $yourOrderNumber;
173
    /** @var string|null */
174
    private $yourReference;
175
    /** @var string|null */
176
    private $zipCode;
177
178 2
    private function __construct()
179
    {
180 2
    }
181
182 2
    public static function createFromArray(array $data)
183
    {
184 2
        $model = new self();
185 2
        $data = $data['Invoice'] ?? $data;
186
187 2
        $model->url = $data['@url'] ?? null;
188 2
        $model->urlTaxReductionList = $data['@urlTaxReductionList'] ?? null;
189 2
        $model->address1 = $data['Address1'] ?? '';
190 2
        $model->address2 = $data['Address2'] ?? '';
191 2
        $model->administrationFee = $data['AdministrationFee'] ?? null;
192 2
        $model->administrationFeeVat = $data['AdministrationFeeVAT'] ?? null;
193 2
        $model->balance = $data['Balance'] ?? null;
194 2
        $model->basisTaxReduction = $data['BasisTaxReduction'] ?? null;
195 2
        $model->booked = $data['Booked'] ?? false;
196 2
        $model->cancelled = $data['Cancelled'] ?? false;
197 2
        $model->city = $data['City'] ?? '';
198 2
        $model->comments = $data['Comments'] ?? '';
199 2
        $model->contractReference = $data['ContractReference'] ?? null;
200 2
        $model->contributionPercent = $data['ContributionPercent'] ?? null;
201 2
        $model->contributionValue = $data['ContributionValue'] ?? null;
202 2
        $model->costCenter = $data['CostCenter'] ?? '';
203 2
        $model->country = $data['Country'] ?? '';
204 2
        $model->credit = $data['Credit'] ?? null;
205 2
        $model->creditInvoiceReference = $data['CreditInvoiceReference'] ?? null;
206 2
        $model->currency = $data['Currency'] ?? null;
207 2
        $model->currencyRate = $data['CurrencyRate'] ?? 1;
208 2
        $model->currencyUnit = $data['CurrencyUnit'] ?? 1;
209 2
        $model->customerName = $data['CustomerName'] ?? null;
210 2
        $model->customerNumber = $data['CustomerNumber'] ?? null;
211 2
        $model->deliveryAddress1 = $data['DeliveryAddress1'] ?? null;
212 2
        $model->deliveryAddress2 = $data['DeliveryAddress2'] ?? null;
213 2
        $model->deliveryCity = $data['deliveryCity'] ?? '';
214 2
        $model->deliveryCountry = $data['deliveryCountry'] ?? '';
215 2
        $model->deliveryDate = $data['DeliveryDate'] ?? null;
216 2
        $model->deliveryName = $data['DeliveryName'] ?? '';
217 2
        $model->deliveryZipCode = $data['DeliveryZipCode'] ?? '';
218 2
        $model->documentNumber = $data['DocumentNumber'] ?? null;
219 2
        $model->dueDate = $data['DueDate'] ?? null;
220 2
        $model->ediInformation = $data['EDIInformation'] ?? [];
221 2
        $model->euQuarterlyReport = $data['EUQuarterlyReport'] ?? false;
222 2
        $model->emailInformation = $data['EmailInformation'] ?? [];
223 2
        $model->externalInvoiceReference1 = $data['externalInvoiceReference1'] ?? null;
224 2
        $model->externalInvoiceReference2 = $data['externalInvoiceReference2'] ?? null;
225 2
        $model->freight = $data['Freight'] ?? null;
226 2
        $model->freightVat = $data['FreightVAT'] ?? null;
227 2
        $model->gross = $data['Gross'] ?? null;
228 2
        $model->houseWork = $data['HouseWork'] ?? false;
229 2
        $model->invoiceDate = $data['InvoiceDate'] ?? null;
230 2
        $model->invoicePeriodEnd = $data['InvoicePeriodEnd'] ?? null;
231 2
        $model->invoicePeriodStart = $data['InvoicePeriodStart'] ?? null;
232 2
        $model->invoiceReference = $data['InvoiceReference'] ?? null;
233 2
        $model->InvoiceRows = $data['InvoiceRows'] ?? [];
234 2
        $model->invoiceType = $data['InvoiceType'] ?? null;
235 2
        $model->labels = $data['Labels'] ?? [];
236 2
        $model->language = $data['Language'] ?? null;
237 2
        $model->lastRemindDate = $data['LastRemindDate'] ?? null;
238 2
        $model->net = $data['Net'] ?? null;
239 2
        $model->notCompleted = $data['NotCompleted'] ?? null;
240 2
        $model->ocr = $data['OCR'] ?? null;
241 2
        $model->offerReference = $data['OfferReference'] ?? null;
242 2
        $model->orderReference = $data['OrderReference'] ?? null;
243 2
        $model->organisationNumber = $data['OrganisationNumber'] ?? null;
244 2
        $model->ourReference = $data['OurReference'] ?? null;
245 2
        $model->paymentWay = $data['PaymentWay'] ?? null;
246 2
        $model->phone1 = $data['Phone1'] ?? null;
247 2
        $model->phone2 = $data['Phone2'] ?? null;
248 2
        $model->priceList = $data['PriceList'] ?? null;
249 2
        $model->printTemplate = $data['PrintTemplate'] ?? null;
250 2
        $model->project = $data['Project'] ?? null;
251 2
        $model->remarks = $data['Remarks'] ?? null;
252 2
        $model->reminders = $data['Reminders'] ?? null;
253 2
        $model->roundOff = $data['RoundOff'] ?? null;
254 2
        $model->sent = $data['Sent'] ?? false;
255 2
        $model->taxReduction = $data['TaxReduction'] ?? null;
256 2
        $model->termsOfDelivery = $data['TermsOfDelivery'] ?? null;
257 2
        $model->termsOfPayment = $data['TermsOfPayment'] ?? null;
258 2
        $model->total = $data['Total'] ?? null;
259 2
        $model->totalToPay = $data['TotalToPay'] ?? null;
260 2
        $model->totalVat = $data['TotalVAT'] ?? null;
261 2
        $model->vatIncluded = $data['VATIncluded'] ?? null;
262 2
        $model->voucherNumber = $data['VoucherNumber'] ?? null;
263 2
        $model->voucherSeries = $data['VoucherSeries'] ?? null;
264 2
        $model->voucherYear = $data['VoucherYear'] ?? null;
265 2
        $model->wayOfDelivery = $data['WayOfDelivery'] ?? '';
266 2
        $model->yourOrderNumber = $data['YourOrderNumber'] ?? '';
267 2
        $model->yourReference = $data['YourReference'] ?? '';
268 2
        $model->zipCode = $data['ZipCode'] ?? '';
269
270 2
        return $model;
271
    }
272
273
    public function getUrl(): string
274
    {
275
        return $this->url;
276
    }
277
278
    public function getUrlTaxReductionList(): string
279
    {
280
        return $this->urlTaxReductionList;
281
    }
282
283
    public function getAddress1(): string
284
    {
285
        return $this->address1;
286
    }
287
288
    public function getAddress2(): string
289
    {
290
        return $this->address2;
291
    }
292
293
    public function getAdministrationFee(): int
294
    {
295
        return $this->administrationFee;
296
    }
297
298
    public function getAdministrationFeeVat(): int
299
    {
300
        return $this->administrationFeeVat;
301
    }
302
303 1
    public function getBalance(): int
304
    {
305 1
        return $this->balance;
306
    }
307
308
    public function getBasisTaxReduction(): int
309
    {
310
        return $this->basisTaxReduction;
311
    }
312
313
    public function isBooked(): bool
314
    {
315
        return $this->booked;
316
    }
317
318
    public function isCancelled(): bool
319
    {
320
        return $this->cancelled;
321
    }
322
323
    public function getCity(): string
324
    {
325
        return $this->city;
326
    }
327
328
    public function getComments(): string
329
    {
330
        return $this->comments;
331
    }
332
333
    public function getContractReference(): int
334
    {
335
        return $this->contractReference;
336
    }
337
338
    public function getContributionPercent(): float
339
    {
340
        return $this->contributionPercent;
341
    }
342
343
    public function getContributionValue(): int
344
    {
345
        return $this->contributionValue;
346
    }
347
348
    public function getCostCenter(): string
349
    {
350
        return $this->costCenter;
351
    }
352
353
    public function getCountry(): string
354
    {
355
        return $this->country;
356
    }
357
358
    public function getCredit(): string
359
    {
360
        return $this->credit;
361
    }
362
363
    public function getCreditInvoiceReference(): string
364
    {
365
        return $this->creditInvoiceReference;
366
    }
367
368
    public function getCurrency(): string
369
    {
370
        return $this->currency;
371
    }
372
373
    public function getCurrencyRate(): int
374
    {
375
        return $this->currencyRate;
376
    }
377
378
    public function getCurrencyUnit(): int
379
    {
380
        return $this->currencyUnit;
381
    }
382
383
    public function getCustomerName(): string
384
    {
385
        return $this->customerName;
386
    }
387
388
    public function getCustomerNumber(): string
389
    {
390
        return $this->customerNumber;
391
    }
392
393
    public function getDeliveryAddress1(): string
394
    {
395
        return $this->deliveryAddress1;
396
    }
397
398
    public function getDeliveryAddress2(): string
399
    {
400
        return $this->deliveryAddress2;
401
    }
402
403
    public function getDeliveryCity(): string
404
    {
405
        return $this->deliveryCity;
406
    }
407
408
    public function getDeliveryCountry(): string
409
    {
410
        return $this->deliveryCountry;
411
    }
412
413
    public function getDeliveryDate(): \DateTimeInterface
414
    {
415
        return new \DateTime($this->deliveryDate);
416
    }
417
418
    public function getDeliveryName(): string
419
    {
420
        return $this->deliveryName;
421
    }
422
423
    public function getDeliveryZipCode(): string
424
    {
425
        return $this->deliveryZipCode;
426
    }
427
428
    public function getDocumentNumber(): string
429
    {
430
        return $this->documentNumber;
431
    }
432
433
    public function getDueDate(): \DateTimeInterface
434
    {
435
        return new \DateTime($this->dueDate);
436
    }
437
438
    public function getEdiInformation(): array
439
    {
440
        return $this->ediInformation;
441
    }
442
443
    public function getEuQuarterlyReport(): string
444
    {
445
        return $this->euQuarterlyReport;
446
    }
447
448
    public function getEmailInformation(): array
449
    {
450
        return $this->emailInformation;
451
    }
452
453
    public function getExternalInvoiceReference1(): string
454
    {
455
        return $this->externalInvoiceReference1;
456
    }
457
458
    public function getExternalInvoiceReference2(): string
459
    {
460
        return $this->externalInvoiceReference2;
461
    }
462
463
    public function getFreight(): int
464
    {
465
        return $this->freight;
466
    }
467
468
    public function getFreightVat(): float
469
    {
470
        return $this->freightVat;
471
    }
472
473
    public function getGross(): int
474
    {
475
        return $this->gross;
476
    }
477
478
    public function isHouseWork(): bool
479
    {
480
        return $this->houseWork;
481
    }
482
483
    public function getInvoiceDate(): \DateTimeInterface
484
    {
485
        return new \DateTime($this->invoiceDate);
486
    }
487
488
    public function getInvoicePeriodEnd(): string
489
    {
490
        return $this->invoicePeriodEnd;
491
    }
492
493
    public function getInvoicePeriodStart(): string
494
    {
495
        return $this->invoicePeriodStart;
496
    }
497
498
    public function getInvoiceReference(): string
499
    {
500
        return $this->invoiceReference;
501
    }
502
503
    public function getInvoiceRows(): array
504
    {
505
        return $this->InvoiceRows;
506
    }
507
508
    public function getInvoiceType(): string
509
    {
510
        return $this->invoiceType;
511
    }
512
513
    public function getLabels(): array
514
    {
515
        return $this->labels;
516
    }
517
518
    public function getLanguage(): string
519
    {
520
        return $this->language;
521
    }
522
523
    public function getLastRemindDate(): \DateTimeInterface
524
    {
525
        return new \DateTime($this->lastRemindDate);
526
    }
527
528
    public function getNet(): string
529
    {
530
        return $this->net;
531
    }
532
533
    public function getNotCompleted(): bool
534
    {
535
        return $this->notCompleted;
536
    }
537
538
    public function getOcr(): string
539
    {
540
        return $this->ocr;
541
    }
542
543
    public function getOfferReference(): string
544
    {
545
        return $this->offerReference;
546
    }
547
548
    public function getOrderReference(): string
549
    {
550
        return $this->orderReference;
551
    }
552
553
    public function getOrganisationNumber(): string
554
    {
555
        return $this->organisationNumber;
556
    }
557
558
    public function getOurReference(): string
559
    {
560
        return $this->ourReference;
561
    }
562
563
    public function getPaymentWay(): string
564
    {
565
        return $this->paymentWay;
566
    }
567
568
    public function getPhone1(): string
569
    {
570
        return $this->phone1;
571
    }
572
573
    public function getPhone2(): string
574
    {
575
        return $this->phone2;
576
    }
577
578
    public function getPriceList(): string
579
    {
580
        return $this->priceList;
581
    }
582
583
    public function getPrintTemplate(): string
584
    {
585
        return $this->printTemplate;
586
    }
587
588
    public function getProject(): string
589
    {
590
        return $this->project;
591
    }
592
593
    public function getRemarks(): string
594
    {
595
        return $this->remarks;
596
    }
597
598
    public function getReminders(): string
599
    {
600
        return $this->reminders;
601
    }
602
603
    public function getRoundOff(): string
604
    {
605
        return $this->roundOff;
606
    }
607
608
    public function isSent(): bool
609
    {
610
        return $this->sent;
611
    }
612
613
    public function getTaxReduction(): string
614
    {
615
        return $this->taxReduction;
616
    }
617
618
    public function getTermsOfDelivery(): string
619
    {
620
        return $this->termsOfDelivery;
621
    }
622
623
    public function getTermsOfPayment(): string
624
    {
625
        return $this->termsOfPayment;
626
    }
627
628
    public function getTotal(): int
629
    {
630
        return $this->total;
631
    }
632
633
    public function getTotalToPay(): int
634
    {
635
        return $this->totalToPay;
636
    }
637
638
    public function getTotalVat(): float
639
    {
640
        return $this->totalVat;
641
    }
642
643
    public function getVatIncluded(): bool
644
    {
645
        return $this->vatIncluded;
646
    }
647
648
    public function getVoucherNumber(): string
649
    {
650
        return $this->voucherNumber;
651
    }
652
653
    public function getVoucherSeries(): string
654
    {
655
        return $this->voucherSeries;
656
    }
657
658
    public function getVoucherYear(): string
659
    {
660
        return $this->voucherYear;
661
    }
662
663
    public function getWayOfDelivery(): string
664
    {
665
        return $this->wayOfDelivery;
666
    }
667
668
    public function getYourOrderNumber(): string
669
    {
670
        return $this->yourOrderNumber;
671
    }
672
673
    public function getYourReference(): string
674
    {
675
        return $this->yourReference;
676
    }
677
678
    public function getZipCode(): string
679
    {
680
        return $this->zipCode;
681
    }
682
}
683