ChangeSets::getObjectChangeSet()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\SkeletonMapper\UnitOfWork;
6
7
use function spl_object_hash;
8
9
class ChangeSets
10
{
11
    /** @var ChangeSet[] */
12
    private $changeSets = [];
13
14
    /**
15
     * @param object $object
16
     */
17 12
    public function addObjectChange($object, Change $change) : void
18
    {
19 12
        $this->getObjectChangeSet($object)->addChange($change);
20 12
    }
21
22
    /**
23
     * @param object $object
24
     */
25 12
    public function getObjectChangeSet($object) : ChangeSet
26
    {
27 12
        $oid = spl_object_hash($object);
28
29 12
        if (! isset($this->changeSets[$oid])) {
30 12
            $this->changeSets[$oid] = new ChangeSet($object);
31
        }
32
33 12
        return $this->changeSets[$oid];
34
    }
35
}
36