Passed
Pull Request — master (#84)
by Frank
12:22
created

EventStager::stage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
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