Passed
Pull Request — master (#84)
by Frank
14:29 queued 04:27
created

EventStager   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 19
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\AggregateRoot;
8
use EventSauce\EventSourcing\AggregateRootId;
9
use EventSauce\EventSourcing\AggregateRootRepository;
10
use EventSauce\EventSourcing\InMemoryMessageRepository;
11
12
class EventStager
13
{
14
    /**
15
     * @phpstan-param AggregateRootRepository<AggregateRoot> $repository
16
     */
17
    public function __construct(
18
        private AggregateRootId $id,
19
        private InMemoryMessageRepository $messageRepository,
20
        private AggregateRootRepository $repository,
21
        private AggregateRootTestCase $testCase
22
    ) {
23
    }
24
25
    public function stage(object ...$events): AggregateRootTestCase
26
    {
27
        $this->repository->persistEvents($this->id, count($events), ...$events);
28
        $this->messageRepository->purgeLastCommit();
29
30
        return $this->testCase;
31
    }
32
}
33