ChangeSet::getChanges()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\SkeletonMapper\UnitOfWork;
6
7
class ChangeSet
8
{
9
    /** @var object */
10
    private $object;
11
12
    /** @var Change[] */
13
    private $changes = [];
14
15
    /**
16
     * @param object   $object
17
     * @param Change[] $changes
18
     */
19 14
    public function __construct($object, array $changes = [])
20
    {
21 14
        $this->object  = $object;
22 14
        $this->changes = $changes;
23 14
    }
24
25
    /**
26
     * @return object
27
     */
28 1
    public function getObject()
29
    {
30 1
        return $this->object;
31
    }
32
33 13
    public function addChange(Change $change) : void
34
    {
35 13
        $this->changes[$change->getPropertyName()] = $change;
36 13
    }
37
38
    /**
39
     * @return Change[]
40
     */
41 10
    public function getChanges() : array
42
    {
43 10
        return $this->changes;
44
    }
45
46 1
    public function hasChangedField(string $fieldName) : bool
47
    {
48 1
        return isset($this->changes[$fieldName]);
49
    }
50
51 1
    public function getFieldChange(string $fieldName) : ?Change
52
    {
53 1
        return $this->changes[$fieldName] ?? null;
54
    }
55
}
56