Passed
Push — master ( d2bca0...659124 )
by Frank
02:12
created

DummyAggregate   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 11
c 3
b 0
f 0
dl 0
loc 49
ccs 22
cts 22
cp 1
rs 10
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A dontDoAnything() 0 2 1
A applyAggregateWasInitiated() 0 2 1
A increment() 0 4 1
A applyDummyIncrementingHappened() 0 3 1
A throwAnException() 0 3 1
A performDummyTask() 0 3 1
A create() 0 6 1
A applyDummyTaskWasExecuted() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EventSauce\EventSourcing\Integration\TestingAggregates;
6
7
use EventSauce\EventSourcing\AggregateRoot;
8
use EventSauce\EventSourcing\AggregateRootBehaviour;
9
10
class DummyAggregate implements AggregateRoot
11
{
12
    use AggregateRootBehaviour;
13
14
    private $incrementedNumber = 0;
15
16 1
    public static function create(DummyAggregateRootId $aggregateRootId)
17
    {
18 1
        $aggregate = new static($aggregateRootId);
19 1
        $aggregate->recordThat(new AggregateWasInitiated());
20
21 1
        return $aggregate;
22
    }
23
24 1
    protected function applyAggregateWasInitiated()
25
    {
26
        // cool
27 1
    }
28
29 1
    public function performDummyTask()
30
    {
31 1
        $this->recordThat(new DummyTaskWasExecuted());
32 1
    }
33
34 3
    public function increment()
35
    {
36 3
        $this->recordThat(new DummyIncrementingHappened(
37 3
            $this->incrementedNumber + 1
38
        ));
39 3
    }
40
41 3
    protected function applyDummyIncrementingHappened(DummyIncrementingHappened $event)
42
    {
43 3
        $this->incrementedNumber = $event->number();
44 3
    }
45
46 1
    protected function applyDummyTaskWasExecuted(/** @scrutinizer ignore-unused */ DummyTaskWasExecuted $event)
47
    {
48
49 1
    }
50
51 1
    public function dontDoAnything()
52
    {
53
        // not doing anything.
54 1
    }
55
56 3
    public function throwAnException()
57
    {
58 3
        throw new DummyException();
59
    }
60
}
61