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

Payment::getRegionName()   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 Shoman4eg\Nalog\Model\CreatableFromArray;
7
8
/**
9
 * @author Artem Dubinin <[email protected]>
10
 */
11
final class Payment implements CreatableFromArray
12
{
13
    private string $sourceType;
14
    private string $type;
15
    private string $documentIndex;
16
    private float $amount;
17
    private \DateTimeImmutable $operationDate;
18
    private \DateTimeImmutable $dueDate;
19
    private string $oktmo;
20
    private string $kbk;
21
    private string $status;
22
    private int $taxPeriodId;
23
    private string $regionName;
24
    private ?\DateTimeImmutable $krsbAcceptedDate;
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
        $model->sourceType = $data['sourceType'];
37
        $model->type = $data['type'];
38
        $model->documentIndex = $data['documentIndex'];
39
        $model->amount = $data['amount'];
40
        $model->operationDate = new \DateTimeImmutable($data['operationDate']);
41
        $model->dueDate = new \DateTimeImmutable($data['dueDate']);
42
        $model->oktmo = $data['oktmo'];
43
        $model->kbk = $data['kbk'];
44
        $model->status = $data['status'];
45
        $model->taxPeriodId = $data['taxPeriodId'];
46
        $model->regionName = $data['regionName'];
47
        $model->krsbAcceptedDate = $data['krsbAcceptedDate']
48
            ? new \DateTimeImmutable($data['krsbAcceptedDate'])
49
            : null;
50
51
        return $model;
52
    }
53
54
    public function getSourceType(): string
55
    {
56
        return $this->sourceType;
57
    }
58
59
    public function getKrsbAcceptedDate(): ?\DateTimeImmutable
60
    {
61
        return $this->krsbAcceptedDate;
62
    }
63
64
    public function getType(): string
65
    {
66
        return $this->type;
67
    }
68
69
    public function getDocumentIndex(): string
70
    {
71
        return $this->documentIndex;
72
    }
73
74
    public function getAmount(): float
75
    {
76
        return $this->amount;
77
    }
78
79
    public function getOperationDate(): \DateTimeImmutable
80
    {
81
        return $this->operationDate;
82
    }
83
84
    public function getDueDate(): \DateTimeImmutable
85
    {
86
        return $this->dueDate;
87
    }
88
89
    public function getOktmo(): string
90
    {
91
        return $this->oktmo;
92
    }
93
94
    public function getStatus(): string
95
    {
96
        return $this->status;
97
    }
98
99
    public function getKbk(): string
100
    {
101
        return $this->kbk;
102
    }
103
104
    public function getTaxPeriodId(): int
105
    {
106
        return $this->taxPeriodId;
107
    }
108
109
    public function getRegionName(): string
110
    {
111
        return $this->regionName;
112
    }
113
}
114