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

Payment::getAmount()   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 Payment implements CreatableFromArray
13
{
14
    private string $sourceType;
15
    private string $type;
16
    private string $documentIndex;
17
    private float $amount;
18
    private DateTimeImmutable $operationDate;
19
    private DateTimeImmutable $dueDate;
20
    private string $oktmo;
21
    private string $kbk;
22
    private string $status;
23
    private int $taxPeriodId;
24
    private string $regionName;
25
    private ?DateTimeImmutable $krsbAcceptedDate;
26
27
    /**
28
     * @throws \Exception
29
     */
30
    public static function createFromArray(array $data): self
31
    {
32
        $model = new self();
33
        $model->sourceType = $data['sourceType'];
34
        $model->type = $data['type'];
35
        $model->documentIndex = $data['documentIndex'];
36
        $model->amount = $data['amount'];
37
        $model->operationDate = new DateTimeImmutable($data['operationDate']);
38
        $model->dueDate = new DateTimeImmutable($data['dueDate']);
39
        $model->oktmo = $data['oktmo'];
40
        $model->kbk = $data['kbk'];
41
        $model->status = $data['status'];
42
        $model->taxPeriodId = $data['taxPeriodId'];
43
        $model->regionName = $data['regionName'];
44
        $model->krsbAcceptedDate = $data['krsbAcceptedDate'] ? new DateTimeImmutable($data['krsbAcceptedDate']) : null;
45
46
        return $model;
47
    }
48
49
    public function getSourceType(): string
50
    {
51
        return $this->sourceType;
52
    }
53
54
    public function getKrsbAcceptedDate(): ?DateTimeImmutable
55
    {
56
        return $this->krsbAcceptedDate;
57
    }
58
59
    public function getType(): string
60
    {
61
        return $this->type;
62
    }
63
64
    public function getDocumentIndex(): string
65
    {
66
        return $this->documentIndex;
67
    }
68
69
    public function getAmount(): float
70
    {
71
        return $this->amount;
72
    }
73
74
    public function getOperationDate(): DateTimeImmutable
75
    {
76
        return $this->operationDate;
77
    }
78
79
    public function getDueDate(): DateTimeImmutable
80
    {
81
        return $this->dueDate;
82
    }
83
84
    public function getOktmo(): string
85
    {
86
        return $this->oktmo;
87
    }
88
89
    public function getStatus(): string
90
    {
91
        return $this->status;
92
    }
93
94
    public function getKbk(): string
95
    {
96
        return $this->kbk;
97
    }
98
99
    public function getTaxPeriodId(): int
100
    {
101
        return $this->taxPeriodId;
102
    }
103
104
    public function getRegionName(): string
105
    {
106
        return $this->regionName;
107
    }
108
}
109