Passed
Pull Request — master (#84)
by Frank
10:15 queued 08:09
created

EventStager   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 36
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A stage() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EventSauce\EventSourcing\TestUtilities;
6
7
use EventSauce\EventSourcing\AggregateRootId;
8
use EventSauce\EventSourcing\AggregateRootRepository;
9
use EventSauce\EventSourcing\InMemoryMessageRepository;
10
11
class EventStager
12
{
13
    /**
14
     * @var AggregateRootId
15
     */
16
    private $id;
17
18
    /**
19
     * @var AggregateRootRepository
20
     */
21
    private $repository;
22
23
    /**
24
     * @var AggregateRootTestCase
25
     */
26
    private $testCase;
27
28
    /**
29
     * @var InMemoryMessageRepository
30
     */
31
    private $messageRepository;
32
33 1
    public function __construct(AggregateRootId $id, InMemoryMessageRepository $messageRepository, AggregateRootRepository $repository, AggregateRootTestCase $testCase)
34
    {
35 1
        $this->id = $id;
36 1
        $this->repository = $repository;
37 1
        $this->testCase = $testCase;
38 1
        $this->messageRepository = $messageRepository;
39 1
    }
40
41 1
    public function stage(object ...$events): AggregateRootTestCase
42
    {
43 1
        $this->repository->persistEvents($this->id, count($events), ...$events);
44 1
        $this->messageRepository->purgeLastCommit();
45
46 1
        return $this->testCase;
47
    }
48
}
49