RecordDiff::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * File was created 05.02.2015 21:29
4
 */
5
6
namespace PeekAndPoke\Component\Slumber\Data\Addon\Journal\DomainModel;
7
8
/**
9
 * @author Karsten J. Gerber <[email protected]>
10
 */
11
class RecordDiff
12
{
13
    /** @var \DateTime */
14
    private $changeDate;
15
    /** @var string */
16
    private $changedBy;
17
    /** @var RecordDiffEntry[] */
18
    private $changes = [];
19
20
    /**
21
     * @param \DateTime $changeDate
22
     * @param string    $changedBy
23
     */
24 3
    public function __construct(\DateTime $changeDate, $changedBy)
25
    {
26 3
        $this->changeDate = $changeDate;
27 3
        $this->changedBy  = $changedBy;
28 3
    }
29
30
    /**
31
     * @return \DateTime
32
     */
33 3
    public function getChangeDate()
34
    {
35 3
        return $this->changeDate;
36
    }
37
38
    /**
39
     * @return string
40
     */
41 3
    public function getChangedBy()
42
    {
43 3
        return $this->changedBy;
44
    }
45
46
    /**
47
     * @return RecordDiffEntry[]
48
     */
49 3
    public function getChanges()
50
    {
51 3
        ksort($this->changes);
52
53 3
        return $this->changes;
54
    }
55
56
    /**
57
     * @return int
58
     */
59 3
    public function getChangesCount()
60
    {
61 3
        return \count($this->changes);
62
    }
63
64
    /**
65
     * @param RecordDiffEntry $change
66
     *
67
     * @return $this
68
     */
69 3
    public function addChange(RecordDiffEntry $change)
70
    {
71 3
        $this->changes[$change->getKey()] = $change;
72
73 3
        return $this;
74
    }
75
}
76