| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php declare (strict_types=1); |
||
| 20 | public function handle(EnvelopeInterface $envelope): void |
||
| 21 | { |
||
| 22 | $message = $envelope->getMessage(); |
||
| 23 | $shortName = (new ReflectionClass($message))->getShortName(); |
||
| 24 | $handlerMethod = 'when'.ucfirst($shortName); |
||
| 25 | $handler = [$this, $handlerMethod]; |
||
| 26 | if (!is_callable($handler)) { |
||
| 27 | throw new RuntimeException( |
||
| 28 | sprintf("Handler method '%s' is not callable in '%s'.", $handlerMethod, static::class) |
||
| 29 | ); |
||
| 30 | } |
||
| 31 | $handler($message, $envelope->getMetadata()); |
||
| 32 | } |
||
| 39 |