Conditions | 6 |
Paths | 12 |
Total Lines | 24 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
33 | 9 | public function handle($command): void |
|
34 | { |
||
35 | try { |
||
36 | 9 | if ($command instanceof InitiatorCommand) { |
|
37 | 1 | $aggregate = DummyAggregate::create($command->aggregateRootId()); |
|
38 | 1 | goto end; |
|
39 | } |
||
40 | |||
41 | /** @var DummyAggregate $aggregate */ |
||
42 | /** @var DummyCommand $command */ |
||
43 | 8 | $aggregate = $this->repository->retrieve($command->aggregateRootId()); |
|
44 | |||
45 | 8 | if ($command instanceof DummyCommand) { |
|
|
|||
46 | 1 | $aggregate->performDummyTask(); |
|
47 | 7 | } elseif ($command instanceof IgnoredCommand) { |
|
48 | 1 | $aggregate->dontDoAnything(); |
|
49 | 6 | } elseif ($command instanceof ExceptionInducingCommand) { |
|
50 | 3 | $aggregate->throwAnException(); |
|
51 | 3 | } elseif ($command instanceof DummyIncrementCommand) { |
|
52 | 3 | $aggregate->increment(); |
|
53 | } |
||
54 | end: |
||
55 | 6 | } finally { |
|
56 | 9 | $this->repository->persist($aggregate); |
|
57 | } |
||
60 |