Passed
Pull Request — master (#33)
by Frank
05:08
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
namespace EventSauce\EventSourcing;
4
5
use Generator;
6
7
class ReconstitutableAggregateRootFactory implements AggregateRootFactory
8
{
9
    /**
10
     * @var string
11
     */
12
    private $className;
13
14 10
    public function __construct(string $className)
15
    {
16 10
        $this->className = $className;
17 10
    }
18
19 8
    public function reconstituteFromEvents(AggregateRootId $aggregateRootId, Generator $events): AggregateRoot
20
    {
21
        /** @var ReconstitutableAggregateRoot $className */
22 8
        $className = $this->className;
23
24 8
        return $className::reconstituteFromEvents($aggregateRootId, $events);
25
    }
26
}