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

History::createFromArray()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 19
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 16
c 1
b 0
f 1
nc 4
nop 1
dl 0
loc 19
rs 9.7333
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 History implements CreatableFromArray
12
{
13
    private int $taxPeriodId;
14
    private float $taxAmount;
15
    private float $bonusAmount;
16
    private float $paidAmount;
17
    private ?float $taxBaseAmount;
18
    private ?\DateTimeImmutable $chargeDate;
19
    private ?\DateTimeImmutable $dueDate;
20
    private string $oktmo;
21
    private string $regionName;
22
    private string $kbk;
23
    private string $taxOrganCode;
24
    private string $type;
25
    private int $krsbTaxChargeId;
26
    private int $receiptCount;
27
28
    private function __construct()
29
    {
30
    }
31
32
    /**
33
     * @throws \Exception
34
     */
35
    public static function createFromArray(array $data): self
36
    {
37
        $model = new self();
38
        $model->taxPeriodId = $data['taxPeriodId'];
39
        $model->taxAmount = $data['taxAmount'];
40
        $model->bonusAmount = $data['bonusAmount'];
41
        $model->paidAmount = $data['paidAmount'];
42
        $model->taxBaseAmount = $data['taxBaseAmount'];
43
        $model->chargeDate = $data['chargeDate'] ? new \DateTimeImmutable($data['chargeDate']) : null;
44
        $model->dueDate = $data['dueDate'] ? new \DateTimeImmutable($data['dueDate']) : null;
45
        $model->oktmo = $data['oktmo'];
46
        $model->regionName = $data['regionName'];
47
        $model->kbk = $data['kbk'];
48
        $model->taxOrganCode = $data['taxOrganCode'];
49
        $model->type = $data['type'];
50
        $model->krsbTaxChargeId = $data['krsbTaxChargeId'];
51
        $model->receiptCount = $data['receiptCount'];
52
53
        return $model;
54
    }
55
56
    public function getPaidAmount(): float
57
    {
58
        return $this->paidAmount;
59
    }
60
61
    public function getBonusAmount(): float
62
    {
63
        return $this->bonusAmount;
64
    }
65
66
    public function getTaxAmount(): float
67
    {
68
        return $this->taxAmount;
69
    }
70
71
    public function getTaxPeriodId(): int
72
    {
73
        return $this->taxPeriodId;
74
    }
75
76
    public function getOktmo(): string
77
    {
78
        return $this->oktmo;
79
    }
80
81
    public function getRegionName(): string
82
    {
83
        return $this->regionName;
84
    }
85
86
    public function getKbk(): string
87
    {
88
        return $this->kbk;
89
    }
90
91
    public function getTaxOrganCode(): string
92
    {
93
        return $this->taxOrganCode;
94
    }
95
96
    public function getKrsbTaxChargeId(): int
97
    {
98
        return $this->krsbTaxChargeId;
99
    }
100
101
    public function getReceiptCount(): int
102
    {
103
        return $this->receiptCount;
104
    }
105
106
    public function getType(): string
107
    {
108
        return $this->type;
109
    }
110
111
    public function getChargeDate(): ?\DateTimeImmutable
112
    {
113
        return $this->chargeDate;
114
    }
115
116
    public function getDueDate(): ?\DateTimeImmutable
117
    {
118
        return $this->dueDate;
119
    }
120
121
    public function getTaxBaseAmount(): ?float
122
    {
123
        return $this->taxBaseAmount;
124
    }
125
}
126