Total Complexity | 8 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Coverage | 86.67% |
Changes | 0 |
1 | <?php |
||
10 | class Balance |
||
11 | { |
||
12 | public const TYPE_OPENING = 'opening'; |
||
13 | |||
14 | public const TYPE_OPENING_AVAILABLE = 'opening_available'; |
||
15 | |||
16 | public const TYPE_CLOSING = 'closing'; |
||
17 | |||
18 | public const TYPE_CLOSING_AVAILABLE = 'closing_available'; |
||
19 | |||
20 | private Money $amount; |
||
21 | |||
22 | private string $type; |
||
23 | |||
24 | private DateTimeImmutable $date; |
||
25 | |||
26 | private function __construct(string $type, Money $amount, DateTimeImmutable $date) |
||
27 | { |
||
28 | $this->type = $type; |
||
29 | $this->amount = $amount; |
||
30 | $this->date = $date; |
||
31 | 12 | } |
|
32 | |||
33 | 12 | public function getDate(): DateTimeImmutable |
|
34 | 12 | { |
|
35 | 12 | return $this->date; |
|
36 | 12 | } |
|
37 | |||
38 | public function getAmount(): Money |
||
39 | { |
||
40 | return $this->amount; |
||
41 | } |
||
42 | |||
43 | 1 | public function getType(): string |
|
44 | { |
||
45 | 1 | return $this->type; |
|
46 | } |
||
47 | |||
48 | 1 | public static function opening(Money $amount, DateTimeImmutable $date): self |
|
49 | { |
||
50 | 1 | return new self(self::TYPE_OPENING, $amount, $date); |
|
51 | } |
||
52 | |||
53 | 12 | public static function openingAvailable(Money $amount, DateTimeImmutable $date): self |
|
54 | { |
||
55 | 12 | return new self(self::TYPE_OPENING_AVAILABLE, $amount, $date); |
|
56 | } |
||
57 | |||
58 | 11 | public static function closing(Money $amount, DateTimeImmutable $date): self |
|
61 | } |
||
62 | |||
63 | public static function closingAvailable(Money $amount, DateTimeImmutable $date): self |
||
64 | { |
||
65 | return new self(self::TYPE_CLOSING_AVAILABLE, $amount, $date); |
||
66 | } |
||
67 | } |
||
68 |