Balance::closing()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Genkgo\Camt\DTO;
6
7
use DateTimeImmutable;
8
use Money\Money;
9
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
59
    {
60 11
        return new self(self::TYPE_CLOSING, $amount, $date);
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