Passed
Pull Request — master (#101)
by Andras
15:04
created

Balance::closingAvailable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
ccs 0
cts 0
cp 0
crap 2
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
    const TYPE_OPENING = 'opening';
13
14
    const TYPE_OPENING_AVAILABLE = 'opening_available';
15
16
    const TYPE_CLOSING = 'closing';
17
18
    const TYPE_CLOSING_AVAILABLE = 'closing_available';
19
20
    /**
21
     * @var Money
22
     */
23
    private $amount;
24
25
    /**
26
     * @var string
27
     */
28
    private $type;
29
30
    /**
31 12
     * @var DateTimeImmutable
32
     */
33 12
    private $date;
34 12
35 12
    private function __construct(string $type, Money $amount, DateTimeImmutable $date)
36 12
    {
37
        $this->type = $type;
38
        $this->amount = $amount;
39
        $this->date = $date;
40
    }
41
42
    public function getDate(): DateTimeImmutable
43 1
    {
44
        return $this->date;
45 1
    }
46
47
    public function getAmount(): Money
48 1
    {
49
        return $this->amount;
50 1
    }
51
52
    public function getType(): string
53 12
    {
54
        return $this->type;
55 12
    }
56
57
    public static function opening(Money $amount, DateTimeImmutable $date): self
58 11
    {
59
        return new self(self::TYPE_OPENING, $amount, $date);
60 11
    }
61
62
    public static function openingAvailable(Money $amount, DateTimeImmutable $date): self
63
    {
64
        return new self(self::TYPE_OPENING_AVAILABLE, $amount, $date);
65
    }
66
67
    public static function closing(Money $amount, DateTimeImmutable $date): self
68
    {
69
        return new self(self::TYPE_CLOSING, $amount, $date);
70
    }
71
72
    public static function closingAvailable(Money $amount, DateTimeImmutable $date): self
73
    {
74
        return new self(self::TYPE_CLOSING_AVAILABLE, $amount, $date);
75
    }
76
}
77