Completed
Pull Request — master (#11)
by Frank
07:25
created

EventStager   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 41
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

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