Completed
Pull Request — master (#33)
by Frank
06:20 queued 03:42
created

ReconstitutableAggregateRootFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A reconstituteFromEvents() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EventSauce\EventSourcing;
6
7
use Generator;
8
9
class ReconstitutableAggregateRootFactory implements AggregateRootFactory
10
{
11
    /**
12
     * @var string
13
     */
14
    private $className;
15
16 10
    public function __construct(string $className)
17
    {
18 10
        $this->className = $className;
19 10
    }
20
21 8
    public function reconstituteFromEvents(AggregateRootId $aggregateRootId, Generator $events): AggregateRoot
22
    {
23
        /** @var ReconstitutableAggregateRoot $className */
24 8
        $className = $this->className;
25
26 8
        return $className::reconstituteFromEvents($aggregateRootId, $events);
27
    }
28
}
29