| Conditions | 5 |
| Paths | 5 |
| Total Lines | 20 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | private function dispatch(object $message): Envelope |
||
| 31 | { |
||
| 32 | if (!$this->messageBus instanceof MessageBusInterface) { |
||
| 33 | throw new \InvalidArgumentException('The message bus is not set.'); |
||
| 34 | } |
||
| 35 | |||
| 36 | if (!class_exists(HandlerFailedException::class)) { |
||
| 37 | return $this->messageBus->dispatch($message); |
||
| 38 | } |
||
| 39 | |||
| 40 | try { |
||
| 41 | return $this->messageBus->dispatch($message); |
||
| 42 | } catch (HandlerFailedException $e) { |
||
| 43 | // unwrap the exception thrown in handler for Symfony Messenger >= 4.3 |
||
| 44 | while ($e instanceof HandlerFailedException) { |
||
| 45 | /** @var \Throwable $e */ |
||
| 46 | $e = $e->getPrevious(); |
||
| 47 | } |
||
| 48 | |||
| 49 | throw $e; |
||
| 50 | } |
||
| 53 |