Passed
Push — master ( 35eebd...7b8a1a )
by Roman
16:45
created

History::changeLevel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Game\Features\History;
6
7
use DateTimeImmutable;
8
9
final class History
10
{
11
    private HistoryId $historyId;
12
    private PlayerId $playerId;
13
    private DateTimeImmutable $createdAt;
14
    private DateTimeImmutable $updatedAt;
15
    private int $level;
16
17
    public function __construct(HistoryId $historyId)
18
    {
19
        $this->historyId = $historyId;
20
        $this->createdAt = new DateTimeImmutable();
21
        $this->updatedAt = new DateTimeImmutable();
22
    }
23
24
    public function changeLevel(int $level): void
25
    {
26
        $this->level = $level;
27
28
        $this->updatedAt = new DateTimeImmutable();
29
    }
30
31
    public function changePlayer(PlayerId $playerId): void
32
    {
33
        $this->playerId = $playerId;
34
35
        $this->updatedAt = new DateTimeImmutable();
36
    }
37
38
    public function historyId(): HistoryId
39
    {
40
        return $this->historyId;
41
    }
42
43
    public function level(): int
44
    {
45
        return $this->level;
46
    }
47
48
    public function createdAt(): DateTimeImmutable
49
    {
50
        return $this->createdAt;
51
    }
52
53
    public function updatedAt(): DateTimeImmutable
54
    {
55
        return $this->updatedAt;
56
    }
57
}
58