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