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

Balance   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 86.67%

Importance

Changes 0
Metric Value
eloc 18
c 0
b 0
f 0
dl 0
loc 65
rs 10
ccs 13
cts 15
cp 0.8667
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 3 1
A __construct() 0 5 1
A opening() 0 3 1
A getAmount() 0 3 1
A getDate() 0 3 1
A closingAvailable() 0 3 1
A closing() 0 3 1
A openingAvailable() 0 3 1
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