Passed
Pull Request — master (#32)
by Artem
01:40
created

Tax   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 39
c 1
b 0
f 1
dl 0
loc 100
rs 10
wmc 15

14 Methods

Rating   Name   Duplication   Size   Complexity  
A getOverpayment() 0 3 1
A getNominalTax() 0 3 1
A __construct() 0 2 1
A getTotal() 0 3 1
A getTax() 0 3 1
A getNominalOverpayment() 0 3 1
A getPenalty() 0 3 1
A createFromArray() 0 18 2
A getTotalForPayment() 0 3 1
A getTaxPeriodId() 0 3 1
A getRegions() 0 3 1
A getDebt() 0 3 1
A getLastPaymentAmount() 0 3 1
A getLastPaymentDate() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoman4eg\Nalog\Model\Tax;
5
6
use Shoman4eg\Nalog\Model\CreatableFromArray;
7
8
/**
9
 * @author Artem Dubinin <[email protected]>
10
 */
11
final class Tax implements CreatableFromArray
12
{
13
    private float $totalForPayment;
14
    private float $total;
15
    private float $tax;
16
    private float $debt;
17
    private float $overpayment;
18
    private float $penalty;
19
    private float $nominalTax;
20
    private float $nominalOverpayment;
21
    private int $taxPeriodId;
22
    private ?float $lastPaymentAmount;
23
    private ?\DateTimeImmutable $lastPaymentDate;
24
    private array $regions;
25
26
    private function __construct()
27
    {
28
    }
29
30
    /**
31
     * @throws \Exception
32
     */
33
    public static function createFromArray(array $data): self
34
    {
35
        $model = new self();
36
37
        $model->totalForPayment = $data['totalForPayment'];
38
        $model->total = $data['total'];
39
        $model->tax = $data['tax'];
40
        $model->debt = $data['debt'];
41
        $model->overpayment = $data['overpayment'];
42
        $model->penalty = $data['penalty'];
43
        $model->nominalTax = $data['nominalTax'];
44
        $model->nominalOverpayment = $data['nominalOverpayment'];
45
        $model->taxPeriodId = $data['taxPeriodId'];
46
        $model->lastPaymentAmount = $data['lastPaymentAmount'];
47
        $model->lastPaymentDate = $data['lastPaymentDate'] ? new \DateTimeImmutable($data['lastPaymentDate']) : null;
48
        $model->regions = $data['regions'];
49
50
        return $model;
51
    }
52
53
    public function getTotalForPayment(): float
54
    {
55
        return $this->totalForPayment;
56
    }
57
58
    public function getTotal(): float
59
    {
60
        return $this->total;
61
    }
62
63
    public function getTax(): float
64
    {
65
        return $this->tax;
66
    }
67
68
    public function getDebt(): float
69
    {
70
        return $this->debt;
71
    }
72
73
    public function getOverpayment(): float
74
    {
75
        return $this->overpayment;
76
    }
77
78
    public function getPenalty(): float
79
    {
80
        return $this->penalty;
81
    }
82
83
    public function getNominalTax(): float
84
    {
85
        return $this->nominalTax;
86
    }
87
88
    public function getNominalOverpayment(): float
89
    {
90
        return $this->nominalOverpayment;
91
    }
92
93
    public function getTaxPeriodId(): int
94
    {
95
        return $this->taxPeriodId;
96
    }
97
98
    public function getLastPaymentAmount(): ?float
99
    {
100
        return $this->lastPaymentAmount;
101
    }
102
103
    public function getLastPaymentDate(): ?\DateTimeImmutable
104
    {
105
        return $this->lastPaymentDate;
106
    }
107
108
    public function getRegions(): array
109
    {
110
        return $this->regions;
111
    }
112
}
113