Passed
Pull Request — master (#32)
by Artem
07:12
created

Tax::getTotalForPayment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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