Conditions | 2 |
Paths | 2 |
Total Lines | 10 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
22 | private function invokeEventHandler(DomainEventInterface $event): ProjectionInterface |
||
23 | { |
||
24 | $handlerName = (new ReflectionClass($event))->getShortName(); |
||
25 | $handlerMethod = 'when'.ucfirst($handlerName); |
||
26 | $projection = clone $this; |
||
27 | $handler = [$projection, $handlerMethod]; |
||
28 | if (!is_callable($handler)) { |
||
29 | throw new RuntimeException("Handler '$handlerMethod' is not callable on ".static::class); |
||
30 | } |
||
31 | return call_user_func($handler, $event); |
||
32 | } |
||
34 |