CancellationInfoType   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 41
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 1 1
A createFromArray() 0 9 1
A getRegisterTime() 0 3 1
A getOperationTime() 0 3 1
A getTaxPeriodId() 0 3 1
A getComment() 0 3 1
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