Customer   F
last analyzed

Complexity

Total Complexity 62

Size/Duplication

Total Lines 495
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 36.56%

Importance

Changes 0
Metric Value
wmc 62
lcom 1
cbo 0
dl 0
loc 495
ccs 68
cts 186
cp 0.3656
rs 3.44
c 0
b 0
f 0

62 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
B createFromArray() 0 67 1
A getUrl() 0 4 1
A getAddress1() 0 4 1
A getAddress2() 0 4 1
A getCity() 0 4 1
A getComments() 0 4 1
A getCostCenter() 0 4 1
A getCountry() 0 4 1
A getCountryCode() 0 4 1
A getCurrency() 0 4 1
A getCustomerNumber() 0 4 1
A getDefaultDeliveryTypes() 0 4 1
A getDefaultTemplates() 0 4 1
A getDeliveryAddress1() 0 4 1
A getDeliveryAddress2() 0 4 1
A getDeliveryCity() 0 4 1
A getDeliveryCountry() 0 4 1
A getDeliveryCountryCode() 0 4 1
A getDeliveryFax() 0 4 1
A getDeliveryName() 0 4 1
A getDeliveryPhone1() 0 4 1
A getDeliveryPhone2() 0 4 1
A getDeliveryZipCode() 0 4 1
A getEmail() 0 4 1
A getEmailInvoice() 0 4 1
A getEmailInvoiceBCC() 0 4 1
A getEmailInvoiceCC() 0 4 1
A getEmailOffer() 0 4 1
A getEmailOfferBCC() 0 4 1
A getEmailOfferCC() 0 4 1
A getEmailOrder() 0 4 1
A getEmailOrderBCC() 0 4 1
A getEmailOrderCC() 0 4 1
A getFax() 0 4 1
A getInvoiceAdministrationFee() 0 4 1
A getInvoiceDiscount() 0 4 1
A getInvoiceFreight() 0 4 1
A getInvoiceRemark() 0 4 1
A getName() 0 4 1
A getOrganisationNumber() 0 4 1
A getOurReference() 0 4 1
A getPhone1() 0 4 1
A getPhone2() 0 4 1
A getPriceList() 0 4 1
A getProject() 0 4 1
A getSalesAccount() 0 4 1
A getShowPriceVATIncluded() 0 4 1
A getTermsOfDelivery() 0 4 1
A getTermsOfPayment() 0 4 1
A getType() 0 4 1
A getVatNumber() 0 4 1
A getVatType() 0 4 1
A getVisitingAddress() 0 4 1
A getVisitingCity() 0 4 1
A getVisitingCountry() 0 4 1
A getVisitingCountryCode() 0 4 1
A getVisitingZipCode() 0 4 1
A getWww() 0 4 1
A getWayOfDelivery() 0 4 1
A getYourReference() 0 4 1
A getZipCode() 0 4 1

How to fix   Complexity   

Complex Class

Complex classes like Customer 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 Customer, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
declare(strict_types=1);
4
5
namespace FAPI\Fortnox\Model\Customer;
6
7
use FAPI\Fortnox\Model\CreatableFromArray;
8
9
final class Customer implements CreatableFromArray
10
{
11
    /** @var string|null */
12
    private $url;
13
    /** @var string|null */
14
    private $address1;
15
    /** @var string|null */
16
    private $address2;
17
    /** @var string|null */
18
    private $city;
19
    /** @var string|null */
20
    private $comments;
21
    /** @var string|null */
22
    private $costCenter;
23
    /** @var string|null */
24
    private $country;
25
    /** @var string|null */
26
    private $countryCode;
27
    /** @var string|null */
28
    private $currency;
29
    /** @var string|null */
30
    private $customerNumber;
31
    /** @var array */
32
    private $defaultDeliveryTypes;
33
    /** @var array */
34
    private $defaultTemplates;
35
    /** @var string|null */
36
    private $deliveryAddress1;
37
    /** @var string|null */
38
    private $deliveryAddress2;
39
    /** @var string|null */
40
    private $deliveryCity;
41
    /** @var string|null */
42
    private $deliveryCountry;
43
    /** @var string|null */
44
    private $deliveryCountryCode;
45
    /** @var string|null */
46
    private $deliveryFax;
47
    /** @var string|null */
48
    private $deliveryName;
49
    /** @var string|null */
50
    private $deliveryPhone1;
51
    /** @var string|null */
52
    private $deliveryPhone2;
53
    /** @var string|null */
54
    private $deliveryZipCode;
55
    /** @var string */
56
    private $email;
57
    /** @var string */
58
    private $emailInvoice;
59
    /** @var string */
60
    private $emailInvoiceBCC;
61
    /** @var string */
62
    private $emailInvoiceCC;
63
    /** @var string */
64
    private $emailOffer;
65
    /** @var string */
66
    private $emailOfferBCC;
67
    /** @var string */
68
    private $emailOfferCC;
69
    /** @var string */
70
    private $emailOrder;
71
    /** @var string */
72
    private $emailOrderBCC;
73
    /** @var string */
74
    private $emailOrderCC;
75
    /** @var string|null */
76
    private $fax;
77
    /** @var string|null */
78
    private $invoiceAdministrationFee;
79
    /** @var string|null */
80
    private $invoiceDiscount;
81
    /** @var string|null */
82
    private $invoiceFreight;
83
    /** @var string|null */
84
    private $invoiceRemark;
85
    /** @var string|null */
86
    private $name;
87
    /** @var string */
88
    private $organisationNumber;
89
    /** @var string */
90
    private $ourReference;
91
    /** @var string|null */
92
    private $phone1;
93
    /** @var string|null */
94
    private $phone2;
95
    /** @var string|null */
96
    private $priceList;
97
    /** @var string|null */
98
    private $project;
99
    /** @var string|null */
100
    private $salesAccount;
101
    /** @var string|null */
102
    private $showPriceVATIncluded;
103
    /** @var string */
104
    private $termsOfDelivery;
105
    /** @var string */
106
    private $termsOfPayment;
107
    /** @var string|null */
108
    private $type;
109
    /** @var string */
110
    private $vatNumber;
111
    /** @var string|null */
112
    private $vatType;
113
    /** @var string|null */
114
    private $visitingAddress;
115
    /** @var string|null */
116
    private $visitingCity;
117
    /** @var string|null */
118
    private $visitingCountry;
119
    /** @var string|null */
120
    private $visitingCountryCode;
121
    /** @var string|null */
122
    private $visitingZipCode;
123
    /** @var string */
124
    private $www;
125
    /** @var string */
126
    private $wayOfDelivery;
127
    /** @var string */
128
    private $yourReference;
129
    /** @var string|null */
130
    private $zipCode;
131
132 2
    private function __construct()
133
    {
134 2
    }
135
136 2
    public static function createFromArray(array $data)
137
    {
138 2
        $model = new self();
139 2
        $data = $data['Customer'] ?? $data;
140 2
        $model->url = $data['@url'] ?? null;
141 2
        $model->address1 = $data['Address1'] ?? null;
142 2
        $model->address2 = $data['Address2'] ?? null;
143 2
        $model->city = $data['City'] ?? null;
144 2
        $model->comments = $data['Comments'] ?? null;
145 2
        $model->costCenter = $data['CostCenter'] ?? null;
146 2
        $model->country = $data['Country'] ?? null;
147 2
        $model->countryCode = $data['CountryCode'] ?? null;
148 2
        $model->currency = $data['Currency'] ?? null;
149 2
        $model->customerNumber = $data['CustomerNumber'] ?? null;
150 2
        $model->defaultDeliveryTypes = $data['DefaultDeliveryTypes'] ?? [];
151 2
        $model->defaultTemplates = $data['DefaultTemplates'] ?? [];
152 2
        $model->deliveryAddress1 = $data['DeliveryAddress1'] ?? null;
153 2
        $model->deliveryAddress2 = $data['DeliveryAddress2'] ?? null;
154 2
        $model->deliveryCity = $data['DeliveryCity'] ?? null;
155 2
        $model->deliveryCountry = $data['DeliveryCountry'] ?? null;
156 2
        $model->deliveryCountryCode = $data['DeliveryCountryCode'] ?? null;
157 2
        $model->deliveryFax = $data['DeliveryFax'] ?? null;
158 2
        $model->deliveryName = $data['DeliveryName'] ?? null;
159 2
        $model->deliveryPhone1 = $data['DeliveryPhone1'] ?? null;
160 2
        $model->deliveryPhone2 = $data['DeliveryPhone2'] ?? null;
161 2
        $model->deliveryZipCode = $data['DeliveryZipCode'] ?? null;
162 2
        $model->email = $data['Email'] ?? '';
163 2
        $model->emailInvoice = $data['EmailInvoice'] ?? '';
164 2
        $model->emailInvoiceBCC = $data['EmailInvoiceBCC'] ?? '';
165 2
        $model->emailInvoiceCC = $data['EmailInvoiceCC'] ?? '';
166 2
        $model->emailOffer = $data['EmailOffer'] ?? '';
167 2
        $model->emailOfferBCC = $data['EmailOfferBCC'] ?? '';
168 2
        $model->emailOfferCC = $data['EmailOfferCC'] ?? '';
169 2
        $model->emailOrder = $data['EmailOrder'] ?? '';
170 2
        $model->emailOrderBCC = $data['EmailOrderBCC'] ?? '';
171 2
        $model->emailOrderCC = $data['EmailOrderCC'] ?? '';
172 2
        $model->fax = $data['Fax'] ?? null;
173 2
        $model->invoiceAdministrationFee = $data['InvoiceAdministrationFee'] ?? null;
174 2
        $model->invoiceDiscount = $data['InvoiceDiscount'] ?? null;
175 2
        $model->invoiceFreight = $data['InvoiceFreight'] ?? null;
176 2
        $model->invoiceRemark = $data['InvoiceRemark'] ?? '';
177 2
        $model->name = $data['Name'] ?? '';
178 2
        $model->organisationNumber = $data['OrganisationNumber'] ?? '';
179 2
        $model->ourReference = $data['OurReference'] ?? '';
180 2
        $model->phone1 = $data['Phone1'] ?? null;
181 2
        $model->phone2 = $data['Phone2'] ?? null;
182 2
        $model->priceList = $data['PriceList'] ?? null;
183 2
        $model->project = $data['Project'] ?? null;
184 2
        $model->salesAccount = $data['SalesAccount'] ?? null;
185 2
        $model->showPriceVATIncluded = $data['ShowPriceVATIncluded'] ?? null;
186 2
        $model->termsOfDelivery = $data['TermsOfDelivery'] ?? '';
187 2
        $model->termsOfPayment = $data['TermsOfPayment'] ?? '';
188 2
        $model->type = $data['Type'] ?? null;
189 2
        $model->vatNumber = $data['VATNumber'] ?? '';
190 2
        $model->vatType = $data['VATType'] ?? null;
191 2
        $model->visitingAddress = $data['VisitingAddress'] ?? null;
192 2
        $model->visitingCity = $data['VisitingCity'] ?? null;
193 2
        $model->visitingCountry = $data['VisitingCountry'] ?? null;
194 2
        $model->visitingCountryCode = $data['VisitingCountryCode'] ?? null;
195 2
        $model->visitingZipCode = $data['VisitingZipCode'] ?? null;
196 2
        $model->www = $data['WWW'] ?? '';
197 2
        $model->wayOfDelivery = $data['WayOfDelivery'] ?? '';
198 2
        $model->yourReference = $data['YourReference'] ?? '';
199 2
        $model->zipCode = $data['ZipCode'] ?? null;
200
201 2
        return $model;
202
    }
203
204
    public function getUrl(): string
205
    {
206
        return $this->url;
207
    }
208
209 1
    public function getAddress1(): string
210
    {
211 1
        return $this->address1;
212
    }
213
214
    public function getAddress2(): string
215
    {
216
        return $this->address2;
217
    }
218
219
    public function getCity(): string
220
    {
221
        return $this->city;
222
    }
223
224
    public function getComments(): string
225
    {
226
        return $this->comments;
227
    }
228
229
    public function getCostCenter(): string
230
    {
231
        return $this->costCenter;
232
    }
233
234
    public function getCountry(): string
235
    {
236
        return $this->country;
237
    }
238
239
    public function getCountryCode(): string
240
    {
241
        return $this->countryCode;
242
    }
243
244
    public function getCurrency(): string
245
    {
246
        return $this->currency;
247
    }
248
249
    public function getCustomerNumber(): string
250
    {
251
        return $this->customerNumber;
252
    }
253
254
    public function getDefaultDeliveryTypes(): array
255
    {
256
        return $this->defaultDeliveryTypes;
257
    }
258
259
    public function getDefaultTemplates(): array
260
    {
261
        return $this->defaultTemplates;
262
    }
263
264
    public function getDeliveryAddress1(): string
265
    {
266
        return $this->deliveryAddress1;
267
    }
268
269
    public function getDeliveryAddress2(): string
270
    {
271
        return $this->deliveryAddress2;
272
    }
273
274
    public function getDeliveryCity(): string
275
    {
276
        return $this->deliveryCity;
277
    }
278
279
    public function getDeliveryCountry(): string
280
    {
281
        return $this->deliveryCountry;
282
    }
283
284
    public function getDeliveryCountryCode(): string
285
    {
286
        return $this->deliveryCountryCode;
287
    }
288
289
    public function getDeliveryFax(): string
290
    {
291
        return $this->deliveryFax;
292
    }
293
294
    public function getDeliveryName(): string
295
    {
296
        return $this->deliveryName;
297
    }
298
299
    public function getDeliveryPhone1(): string
300
    {
301
        return $this->deliveryPhone1;
302
    }
303
304
    public function getDeliveryPhone2(): string
305
    {
306
        return $this->deliveryPhone2;
307
    }
308
309
    public function getDeliveryZipCode(): string
310
    {
311
        return $this->deliveryZipCode;
312
    }
313
314
    public function getEmail(): string
315
    {
316
        return $this->email;
317
    }
318
319
    public function getEmailInvoice(): string
320
    {
321
        return $this->emailInvoice;
322
    }
323
324
    public function getEmailInvoiceBCC(): string
325
    {
326
        return $this->emailInvoiceBCC;
327
    }
328
329
    public function getEmailInvoiceCC(): string
330
    {
331
        return $this->emailInvoiceCC;
332
    }
333
334
    public function getEmailOffer(): string
335
    {
336
        return $this->emailOffer;
337
    }
338
339
    public function getEmailOfferBCC(): string
340
    {
341
        return $this->emailOfferBCC;
342
    }
343
344
    public function getEmailOfferCC(): string
345
    {
346
        return $this->emailOfferCC;
347
    }
348
349
    public function getEmailOrder(): string
350
    {
351
        return $this->emailOrder;
352
    }
353
354
    public function getEmailOrderBCC(): string
355
    {
356
        return $this->emailOrderBCC;
357
    }
358
359
    public function getEmailOrderCC(): string
360
    {
361
        return $this->emailOrderCC;
362
    }
363
364
    public function getFax(): string
365
    {
366
        return $this->fax;
367
    }
368
369
    public function getInvoiceAdministrationFee(): string
370
    {
371
        return $this->invoiceAdministrationFee;
372
    }
373
374
    public function getInvoiceDiscount(): string
375
    {
376
        return $this->invoiceDiscount;
377
    }
378
379
    public function getInvoiceFreight(): string
380
    {
381
        return $this->invoiceFreight;
382
    }
383
384
    public function getInvoiceRemark(): string
385
    {
386
        return $this->invoiceRemark;
387
    }
388
389
    public function getName(): string
390
    {
391
        return $this->name;
392
    }
393
394
    public function getOrganisationNumber(): string
395
    {
396
        return $this->organisationNumber;
397
    }
398
399
    public function getOurReference(): string
400
    {
401
        return $this->ourReference;
402
    }
403
404
    public function getPhone1(): string
405
    {
406
        return $this->phone1;
407
    }
408
409
    public function getPhone2(): string
410
    {
411
        return $this->phone2;
412
    }
413
414
    public function getPriceList(): string
415
    {
416
        return $this->priceList;
417
    }
418
419
    public function getProject(): string
420
    {
421
        return $this->project;
422
    }
423
424
    public function getSalesAccount(): string
425
    {
426
        return $this->salesAccount;
427
    }
428
429
    public function getShowPriceVATIncluded(): string
430
    {
431
        return $this->showPriceVATIncluded;
432
    }
433
434
    public function getTermsOfDelivery(): string
435
    {
436
        return $this->termsOfDelivery;
437
    }
438
439
    public function getTermsOfPayment(): string
440
    {
441
        return $this->termsOfPayment;
442
    }
443
444
    public function getType(): string
445
    {
446
        return $this->type;
447
    }
448
449
    public function getVatNumber(): string
450
    {
451
        return $this->vatNumber;
452
    }
453
454
    public function getVatType(): string
455
    {
456
        return $this->vatType;
457
    }
458
459
    public function getVisitingAddress(): string
460
    {
461
        return $this->visitingAddress;
462
    }
463
464
    public function getVisitingCity(): string
465
    {
466
        return $this->visitingCity;
467
    }
468
469
    public function getVisitingCountry(): string
470
    {
471
        return $this->visitingCountry;
472
    }
473
474
    public function getVisitingCountryCode(): string
475
    {
476
        return $this->visitingCountryCode;
477
    }
478
479
    public function getVisitingZipCode(): string
480
    {
481
        return $this->visitingZipCode;
482
    }
483
484
    public function getWww(): string
485
    {
486
        return $this->www;
487
    }
488
489
    public function getWayOfDelivery(): string
490
    {
491
        return $this->wayOfDelivery;
492
    }
493
494
    public function getYourReference(): string
495
    {
496
        return $this->yourReference;
497
    }
498
499
    public function getZipCode(): string
500
    {
501
        return $this->zipCode;
502
    }
503
}
504