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

DummyAggregate::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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