AggregateRootBehaviourWithRequiredHistory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A reconstituteFromEvents() 0 9 2
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): static
16
    {
17 2
        $aggregateRoot = static::defaultAggregateRootReconstitute($aggregateRootId, $events);
18
19 2
        if (0 === $aggregateRoot->aggregateRootVersion()) {
20 1
            throw UnableToReconstituteAggregateRoot::becauseItHasNoHistory();
21
        }
22
23 1
        return $aggregateRoot;
24
    }
25
}
26