DummyAggregate   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 50
rs 10
c 1
b 0
f 0
wmc 8

8 Methods

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