BookkeepingSetting::toArray()   F
last analyzed

Complexity

Conditions 22
Paths > 20000

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 69
Code Lines 45

Code Coverage

Tests 42
CRAP Score 22.1436

Importance

Changes 0
Metric Value
dl 0
loc 69
ccs 42
cts 45
cp 0.9333
rs 2.6568
c 0
b 0
f 0
cc 22
eloc 45
nc 2097152
nop 0
crap 22.1436

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\Setting;
6
7
use Billogram\Model\CreatableFromArray;
8
9
/**
10
 * @author Ibrahim Hizeoui <[email protected]>
11
 */
12
class BookkeepingSetting implements CreatableFromArray
13
{
14
    /**
15
     * @var string
16
     */
17
    private $incomeAccountForVat25;
18
19
    /**
20
     * @var string
21
     */
22
    private $incomeAccountForVat12;
23
24
    /**
25
     * @var string
26
     */
27
    private $incomeAccountForVat6;
28
29
    /**
30
     * @var string
31
     */
32
    private $incomeAccountForVat0;
33
34
    /**
35
     * @var string
36
     */
37
    private $reversedVatAccount;
38
39
    /**
40
     * @var string
41
     */
42
    private $vatAccountForVat25;
43
44
    /**
45
     * @var string
46
     */
47
    private $vatAccountForVat12;
48
49
    /**
50
     * @var string
51
     */
52
    private $vatAccountForVat6;
53
54
    /**
55
     * @var string
56
     */
57
    private $accountReceivableAccount;
58
59
    /**
60
     * @var string
61
     */
62
    private $clientFundsAccount;
63
64
    /**
65
     * @var string
66
     */
67
    private $bankingAccount;
68
69
    /**
70
     * @var string
71
     */
72
    private $interestFeeAccount;
73
74
    /**
75
     * @var string
76
     */
77
    private $reminderFeeAccount;
78
79
    /**
80
     * @var string
81
     */
82
    private $roundingAccount;
83
84
    /**
85
     * @var string
86
     */
87
    private $factoringReceivableAccount;
88
89
    /**
90
     * @var string
91
     */
92
    private $nonAllocatedAccount;
93
94
    /**
95
     * @var string
96
     */
97
    private $incomePayoutAccount;
98
99
    /**
100
     * @var string
101
     */
102
    private $writtenDownReceivablesAccount;
103
104
    /**
105
     * @var string
106
     */
107
    private $expectedLossAccount;
108
109
    /**
110
     * @var array
111
     */
112
    private $regionalSweden;
113
114
    /**
115
     * @return string
116
     */
117
    public function getIncomeAccountForVat25()
118
    {
119
        return $this->incomeAccountForVat25;
120
    }
121
122
    /**
123
     * @param string $incomeAccountForVat25
124
     *
125
     * @return BookkeepingSetting
126
     */
127
    public function withIncomeAccountForVat25(string $incomeAccountForVat25)
128
    {
129
        $new = clone $this;
130
        $new->incomeAccountForVat25 = $incomeAccountForVat25;
131
132
        return $new;
133
    }
134
135
    /**
136
     * @return string
137
     */
138
    public function getIncomeAccountForVat12()
139
    {
140
        return $this->incomeAccountForVat12;
141
    }
142
143
    /**
144
     * @param string $incomeAccountForVat12
145
     *
146
     * @return BookkeepingSetting
147
     */
148
    public function withIncomeAccountForVat12(string $incomeAccountForVat12)
149
    {
150
        $new = clone $this;
151
        $new->incomeAccountForVat12 = $incomeAccountForVat12;
152
153
        return $new;
154
    }
155
156
    /**
157
     * @return string
158
     */
159
    public function getIncomeAccountForVat6()
160
    {
161
        return $this->incomeAccountForVat6;
162
    }
163
164
    /**
165
     * @param string $incomeAccountForVat6
166
     *
167
     * @return BookkeepingSetting
168
     */
169
    public function withIncomeAccountForVat6(string $incomeAccountForVat6)
170
    {
171
        $new = clone $this;
172
        $new->incomeAccountForVat6 = $incomeAccountForVat6;
173
174
        return $new;
175
    }
176
177
    /**
178
     * @return string
179
     */
180
    public function getIncomeAccountForVat0()
181
    {
182
        return $this->incomeAccountForVat0;
183
    }
184
185
    /**
186
     * @param string $incomeAccountForVat0
187
     *
188
     * @return BookkeepingSetting
189
     */
190
    public function withIncomeAccountForVat0(string $incomeAccountForVat0)
191
    {
192
        $new = clone $this;
193
        $new->incomeAccountForVat0 = $incomeAccountForVat0;
194
195
        return $new;
196
    }
197
198
    /**
199
     * @return string
200
     */
201
    public function getReversedVatAccount()
202
    {
203
        return $this->reversedVatAccount;
204
    }
205
206
    /**
207
     * @param string $reversedVatAccount
208
     *
209
     * @return BookkeepingSetting
210
     */
211
    public function withReversedVatAccount(string $reversedVatAccount)
212
    {
213
        $new = clone $this;
214
        $new->reversedVatAccount = $reversedVatAccount;
215
216
        return $new;
217
    }
218
219
    /**
220
     * @return string
221
     */
222
    public function getVatAccountForVat25()
223
    {
224
        return $this->vatAccountForVat25;
225
    }
226
227
    /**
228
     * @param string $vatAccountForVat25
229
     *
230
     * @return BookkeepingSetting
231
     */
232
    public function withVatAccountForVat25(string $vatAccountForVat25)
233
    {
234
        $new = clone $this;
235
        $new->vatAccountForVat25 = $vatAccountForVat25;
236
237
        return $new;
238
    }
239
240
    /**
241
     * @return string
242
     */
243
    public function getVatAccountForVat12()
244
    {
245
        return $this->vatAccountForVat12;
246
    }
247
248
    /**
249
     * @param string $vatAccountForVat12
250
     *
251
     * @return BookkeepingSetting
252
     */
253
    public function withVatAccountForVat12(string $vatAccountForVat12)
254
    {
255
        $new = clone $this;
256
        $new->vatAccountForVat12 = $vatAccountForVat12;
257
258
        return $new;
259
    }
260
261
    /**
262
     * @return string
263
     */
264
    public function getVatAccountForVat6()
265
    {
266
        return $this->vatAccountForVat6;
267
    }
268
269
    /**
270
     * @param string $vatAccountForVat6
271
     *
272
     * @return BookkeepingSetting
273
     */
274
    public function withVatAccountForVat6(string $vatAccountForVat6)
275
    {
276
        $new = clone $this;
277
        $new->vatAccountForVat6 = $vatAccountForVat6;
278
279
        return $new;
280
    }
281
282
    /**
283
     * @return string
284
     */
285
    public function getAccountReceivableAccount()
286
    {
287
        return $this->accountReceivableAccount;
288
    }
289
290
    /**
291
     * @param string $accountReceivableAccount
292
     *
293
     * @return BookkeepingSetting
294
     */
295
    public function withAccountReceivableAccount(string $accountReceivableAccount)
296
    {
297
        $new = clone $this;
298
        $new->accountReceivableAccount = $accountReceivableAccount;
299
300
        return $new;
301
    }
302
303
    /**
304
     * @return string
305
     */
306
    public function getClientFundsAccount()
307
    {
308
        return $this->clientFundsAccount;
309
    }
310
311
    /**
312
     * @param string $clientFundsAccount
313
     *
314
     * @return BookkeepingSetting
315
     */
316
    public function withClientFundsAccount(string $clientFundsAccount)
317
    {
318
        $new = clone $this;
319
        $new->clientFundsAccount = $clientFundsAccount;
320
321
        return $new;
322
    }
323
324
    /**
325
     * @return string
326
     */
327
    public function getBankingAccount()
328
    {
329
        return $this->bankingAccount;
330
    }
331
332
    /**
333
     * @param string $bankingAccount
334
     *
335
     * @return BookkeepingSetting
336
     */
337
    public function withBankingAccount(string $bankingAccount)
338
    {
339
        $new = clone $this;
340
        $new->bankingAccount = $bankingAccount;
341
342
        return $new;
343
    }
344
345
    /**
346
     * @return string
347
     */
348
    public function getInterestFeeAccount()
349
    {
350
        return $this->interestFeeAccount;
351
    }
352
353
    /**
354
     * @param string $interestFeeAccount
355
     *
356
     * @return BookkeepingSetting
357
     */
358
    public function withInterestFeeAccount(string $interestFeeAccount)
359
    {
360
        $new = clone $this;
361
        $new->interestFeeAccount = $interestFeeAccount;
362
363
        return $new;
364
    }
365
366
    /**
367
     * @return string
368
     */
369
    public function getReminderFeeAccount()
370
    {
371
        return $this->reminderFeeAccount;
372
    }
373
374
    /**
375
     * @param string $reminderFeeAccount
376
     *
377
     * @return BookkeepingSetting
378
     */
379
    public function withReminderFeeAccount(string $reminderFeeAccount)
380
    {
381
        $new = clone $this;
382
        $new->reminderFeeAccount = $reminderFeeAccount;
383
384
        return $new;
385
    }
386
387
    /**
388
     * @return string
389
     */
390
    public function getRoundingAccount()
391
    {
392
        return $this->roundingAccount;
393
    }
394
395
    /**
396
     * @param string $roundingAccount
397
     *
398
     * @return BookkeepingSetting
399
     */
400
    public function withRoundingAccount(string $roundingAccount)
401
    {
402
        $new = clone $this;
403
        $new->roundingAccount = $roundingAccount;
404
405
        return $new;
406
    }
407
408
    /**
409
     * @return string
410
     */
411
    public function getFactoringReceivableAccount()
412
    {
413
        return $this->factoringReceivableAccount;
414
    }
415
416
    /**
417
     * @param string $factoringReceivableAccount
418
     *
419
     * @return BookkeepingSetting
420
     */
421
    public function withFactoringReceivableAccount(string $factoringReceivableAccount)
422
    {
423
        $new = clone $this;
424
        $new->factoringReceivableAccount = $factoringReceivableAccount;
425
426
        return $new;
427
    }
428
429
    /**
430
     * @return string
431
     */
432
    public function getNonAllocatedAccount()
433
    {
434
        return $this->nonAllocatedAccount;
435
    }
436
437
    /**
438
     * @param string $nonAllocatedAccount
439
     *
440
     * @return BookkeepingSetting
441
     */
442
    public function withNonAllocatedAccount(string $nonAllocatedAccount)
443
    {
444
        $new = clone $this;
445
        $new->nonAllocatedAccount = $nonAllocatedAccount;
446
447
        return $new;
448
    }
449
450
    /**
451
     * @return string
452
     */
453
    public function getIncomePayoutAccount()
454
    {
455
        return $this->incomePayoutAccount;
456
    }
457
458
    /**
459
     * @param string $incomePayoutAccount
460
     *
461
     * @return BookkeepingSetting
462
     */
463
    public function withIncomePayoutAccount(string $incomePayoutAccount)
464
    {
465
        $new = clone $this;
466
        $new->incomePayoutAccount = $incomePayoutAccount;
467
468
        return $new;
469
    }
470
471
    /**
472
     * @return string
473
     */
474
    public function getWrittenDownReceivablesAccount()
475
    {
476
        return $this->writtenDownReceivablesAccount;
477
    }
478
479
    /**
480
     * @param string $writtenDownReceivablesAccount
481
     *
482
     * @return BookkeepingSetting
483
     */
484
    public function withWrittenDownReceivablesAccount(string $writtenDownReceivablesAccount)
485
    {
486
        $new = clone $this;
487
        $new->writtenDownReceivablesAccount = $writtenDownReceivablesAccount;
488
489
        return $new;
490
    }
491
492
    /**
493
     * @return string
494
     */
495
    public function getExpectedLossAccount()
496
    {
497
        return $this->expectedLossAccount;
498
    }
499
500
    /**
501
     * @param string $expectedLossAccount
502
     *
503
     * @return BookkeepingSetting
504
     */
505
    public function withExpectedLossAccount(string $expectedLossAccount)
506
    {
507
        $new = clone $this;
508
        $new->expectedLossAccount = $expectedLossAccount;
509
510
        return $new;
511
    }
512
513
    /**
514
     * @return array
515
     */
516
    public function getRegionalSweden()
517
    {
518
        return $this->regionalSweden;
519
    }
520
521
    /**
522
     * @param array $regionalSweden
523
     *
524
     * @return BookkeepingSetting
525
     */
526
    public function withRegionalSweden(array $regionalSweden)
527
    {
528
        $new = clone $this;
529
        $new->regionalSweden = $regionalSweden;
530
531
        return $new;
532
    }
533
534
    /**
535
     * Create an API response object from the HTTP response from the API server.
536
     *
537
     * @param array $data
538
     *
539
     * @return self
540
     */
541 2
    public static function createFromArray(array $data)
542
    {
543 2
        $bookkeeping = new self();
544 2
        $bookkeeping->incomeAccountForVat25 = $data['income_account_for_vat_25'] ?? null;
545 2
        $bookkeeping->incomeAccountForVat12 = $data['income_account_for_vat_12'] ?? null;
546 2
        $bookkeeping->incomeAccountForVat6 = $data['income_account_for_vat_6'] ?? null;
547 2
        $bookkeeping->incomeAccountForVat0 = $data['income_account_for_vat_0'] ?? null;
548 2
        $bookkeeping->reversedVatAccount = $data['reversed_vat_account'] ?? null;
549 2
        $bookkeeping->vatAccountForVat25 = $data['vat_account_for_vat_25'] ?? null;
550 2
        $bookkeeping->vatAccountForVat12 = $data['vat_account_for_vat_12'] ?? null;
551 2
        $bookkeeping->vatAccountForVat6 = $data['vat_account_for_vat_6'] ?? null;
552 2
        $bookkeeping->accountReceivableAccount = $data['account_receivable_account'] ?? null;
553 2
        $bookkeeping->clientFundsAccount = $data['client_funds_account'] ?? null;
554 2
        $bookkeeping->bankingAccount = $data['banking_account'] ?? null;
555 2
        $bookkeeping->interestFeeAccount = $data['interest_fee_account'] ?? null;
556 2
        $bookkeeping->reminderFeeAccount = $data['reminder_fee_account'] ?? null;
557 2
        $bookkeeping->reminderAccount = $data['reminder_account'] ?? null;
0 ignored issues
show
Bug introduced by Ibrahimhizeoui
The property reminderAccount does not seem to exist. Did you mean reminderFeeAccount?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
558 2
        $bookkeeping->factoringReceivableAccount = $data['factoring_receivable_account'] ?? null;
559 2
        $bookkeeping->nonAllocatedAccount = $data['non_allocated_account'] ?? null;
560 2
        $bookkeeping->incomePayoutAccount = $data['income_payout_account'] ?? null;
561 2
        $bookkeeping->writtenDownReceivablesAccount = $data['written_down_receivables_account'] ?? null;
562 2
        $bookkeeping->expectedLossAccount = $data['expected_loss_account'] ?? null;
563 2
        $bookkeeping->regionalSweden['rotavdrag_account'] = $data['regional_sweden']['rotavdrag_account'] ?? null;
564
565 2
        return $bookkeeping;
566
    }
567
568 1
    public function toArray()
569
    {
570 1
        $data = [];
571 1
        if (null !== $this->incomeAccountForVat25) {
572 1
            $data['income_account_for_vat_25'] = $this->incomeAccountForVat25;
573
        }
574 1
        if (null !== $this->incomeAccountForVat12) {
575 1
            $data['income_account_for_vat_25'] = $this->incomeAccountForVat12;
576
        }
577 1
        if (null !== $this->incomeAccountForVat6) {
578
            $data['income_account_for_vat_6'] = $this->incomeAccountForVat6;
579
        }
580 1
        if (null !== $this->incomeAccountForVat0) {
581 1
            $data['income_account_for_vat_0'] = $this->incomeAccountForVat0;
582
        }
583 1
        if (null !== $this->reversedVatAccount) {
584 1
            $data['reversed_vat_account'] = $this->reversedVatAccount;
585
        }
586 1
        if (null !== $this->vatAccountForVat25) {
587 1
            $data['vat_account_for_vat_25'] = $this->vatAccountForVat25;
588
        }
589 1
        if (null !== $this->vatAccountForVat12) {
590 1
            $data['vat_account_for_vat_12'] = $this->vatAccountForVat12;
591
        }
592 1
        if (null !== $this->vatAccountForVat6) {
593 1
            $data['vat_account_for_vat_6'] = $this->vatAccountForVat6;
594
        }
595 1
        if (null !== $this->accountReceivableAccount) {
596 1
            $data['account_receivable_account'] = $this->accountReceivableAccount;
597
        }
598 1
        if (null !== $this->clientFundsAccount) {
599 1
            $data['client_funds_account'] = $this->clientFundsAccount;
600
        }
601 1
        if (null !== $this->bankingAccount) {
602 1
            $data['banking_account'] = $this->bankingAccount;
603
        }
604 1
        if (null !== $this->interestFeeAccount) {
605 1
            $data['interest_fee_account'] = $this->interestFeeAccount;
606
        }
607 1
        if (null !== $this->roundingAccount) {
608
            $data['reminder_account'] = $this->roundingAccount;
609
        }
610 1
        if (null !== $this->reminderFeeAccount) {
611 1
            $data['reminder_fee_account'] = $this->reminderFeeAccount;
612
        }
613 1
        if (null !== $this->roundingAccount) {
614
            $data['rounding_account'] = $this->roundingAccount;
615
        }
616 1
        if (null !== $this->factoringReceivableAccount) {
617 1
            $data['factoring_receivable_account'] = $this->factoringReceivableAccount;
618
        }
619 1
        if (null !== $this->nonAllocatedAccount) {
620 1
            $data['non_allocated_account'] = $this->nonAllocatedAccount;
621
        }
622 1
        if (null !== $this->incomePayoutAccount) {
623 1
            $data['income_payout_account'] = $this->incomePayoutAccount;
624
        }
625 1
        if (null !== $this->writtenDownReceivablesAccount) {
626 1
            $data['written_down_receivables_account'] = $this->writtenDownReceivablesAccount;
627
        }
628 1
        if (null !== $this->expectedLossAccount) {
629 1
            $data['expected_loss_account'] = $this->expectedLossAccount;
630
        }
631 1
        if (null !== $this->regionalSweden['rotavdrag_account']) {
632 1
            $data['regional_sweden']['rotavdrag_account'] = $this->regionalSweden['rotavdrag_account'];
633
        }
634
635 1
        return $data;
636
    }
637
}
638