Conditions | 7 |
Paths | 48 |
Total Lines | 24 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
30 | public function handle(DummyCommand $command): void |
||
31 | { |
||
32 | try { |
||
33 | if ($command instanceof InitiatorCommand) { |
||
34 | $aggregate = DummyAggregate::create($command->aggregateRootId()); |
||
35 | |||
36 | return; |
||
37 | } |
||
38 | |||
39 | /** @var DummyAggregate $aggregate */ |
||
40 | $aggregate = $this->repository->retrieve($command->aggregateRootId()); |
||
41 | |||
42 | if ($command instanceof PerformDummyTask) { |
||
43 | $aggregate->performDummyTask(); |
||
44 | } elseif ($command instanceof IgnoredCommand) { |
||
45 | $aggregate->dontDoAnything(); |
||
46 | } elseif ($command instanceof ExceptionInducingCommand) { |
||
47 | $aggregate->throwAnException(); |
||
48 | } elseif ($command instanceof DummyIncrementCommand) { |
||
49 | $aggregate->increment(); |
||
50 | } |
||
51 | } finally { |
||
52 | if (isset($aggregate)) { |
||
53 | $this->repository->persist($aggregate); |
||
54 | } |
||
58 |