Passed
Push — master ( dbfb37...74a6ed )
by Frank
46s queued 13s
created

reconstituteFromEvents()   A

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 2
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 EventSauce\EventSourcing;
6
7
use Generator;
8
9
trait AggregateRootBehaviourWithRequiredHistory
10
{
11
    use AggregateRootBehaviour {
12
        AggregateRootBehaviour::reconstituteFromEvents as private defaultAggregateRootReconstitute;
13
    }
14
15 2
    public static function reconstituteFromEvents(AggregateRootId $aggregateRootId, Generator $events): AggregateRoot
16
    {
17 2
        $aggregateRoot = static::defaultAggregateRootReconstitute($aggregateRootId, $events);
18
19 2
        if (0 === $aggregateRoot->aggregateRootVersion()) {
20 1
            throw new InvalidAggregateRootReconstitutionException();
21
        }
22
23 1
        return $aggregateRoot;
24
    }
25
}
26