ChangeSet   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 47
ccs 15
cts 15
cp 1
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A hasChangedField() 0 3 1
A getChanges() 0 3 1
A __construct() 0 4 1
A getFieldChange() 0 3 1
A getObject() 0 3 1
A addChange() 0 3 1
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