CancellationInfoType::createFromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 9
rs 10
c 1
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoman4eg\Nalog\Model\Income;
5
6
use Shoman4eg\Nalog\Model\CreatableFromArray;
7
8
/**
9
 * @author Artem Dubinin <[email protected]>
10
 */
11
final class CancellationInfoType implements CreatableFromArray
12
{
13
    private \DateTimeImmutable $operationTime;
14
    private \DateTimeImmutable $registerTime;
15
    private int $taxPeriodId;
16
    private string $comment;
17
18
    private function __construct() {}
19
20
    /**
21
     * @throws \Exception
22
     */
23
    public static function createFromArray(array $data): self
24
    {
25
        $model = new self();
26
        $model->operationTime = new \DateTimeImmutable($data['operationTime']);
27
        $model->registerTime = new \DateTimeImmutable($data['registerTime']);
28
        $model->taxPeriodId = $data['taxPeriodId'];
29
        $model->comment = $data['comment'];
30
31
        return $model;
32
    }
33
34
    public function getOperationTime(): \DateTimeImmutable
35
    {
36
        return $this->operationTime;
37
    }
38
39
    public function getRegisterTime(): \DateTimeImmutable
40
    {
41
        return $this->registerTime;
42
    }
43
44
    public function getTaxPeriodId(): int
45
    {
46
        return $this->taxPeriodId;
47
    }
48
49
    public function getComment(): string
50
    {
51
        return $this->comment;
52
    }
53
}
54