| Conditions | 4 |
| Paths | 1 |
| Total Lines | 34 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 22 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public function __invoke(callable $consume): void |
||
| 31 | { |
||
| 32 | 4 | ($this->get)(function(Message $message, ...$args) use ($consume): void { |
|
| 33 | try { |
||
| 34 | 4 | $this->logger->debug( |
|
| 35 | 4 | 'AMQP message received', |
|
| 36 | 4 | ['body' => (string) $message->body()] |
|
| 37 | ); |
||
| 38 | |||
| 39 | 4 | $consume($message, ...$args); |
|
| 40 | 3 | } catch (Reject $e) { |
|
| 41 | 1 | $this->logger->warning( |
|
| 42 | 1 | 'AMQP message rejected', |
|
| 43 | 1 | ['body' => (string) $message->body()] |
|
| 44 | ); |
||
| 45 | 1 | throw $e; |
|
| 46 | 2 | } catch (Requeue $e) { |
|
| 47 | 1 | $this->logger->info( |
|
| 48 | 1 | 'AMQP message requeued', |
|
| 49 | 1 | ['body' => (string) $message->body()] |
|
| 50 | ); |
||
| 51 | 1 | throw $e; |
|
| 52 | 1 | } catch (\Throwable $e) { |
|
| 53 | 1 | $this->logger->error( |
|
| 54 | 1 | 'AMQP message consumption generated an exception', |
|
| 55 | [ |
||
| 56 | 1 | 'body' => (string) $message->body(), |
|
| 57 | 1 | 'exception' => get_class($e), |
|
| 58 | ] |
||
| 59 | ); |
||
| 60 | 1 | throw $e; |
|
| 61 | } |
||
| 62 | 4 | }); |
|
| 63 | } |
||
| 64 | } |
||
| 65 |