| Total Complexity | 10 |
| Total Lines | 76 |
| Duplicated Lines | 0 % |
| Coverage | 56.76% |
| Changes | 3 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 9 | trait EnvelopeTrait |
||
| 10 | { |
||
| 11 | private MessageInterface $message; |
||
| 12 | |||
| 13 | 4 | public function getMessage(): MessageInterface |
|
| 14 | { |
||
| 15 | 4 | return $this->message; |
|
| 16 | } |
||
| 17 | |||
| 18 | public function withMessage(MessageInterface $message): self |
||
| 19 | { |
||
| 20 | $instance = clone $this; |
||
| 21 | $instance->message = $message; |
||
| 22 | |||
| 23 | return $instance; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @return class-string<MessageHandlerInterface> |
||
|
|
|||
| 28 | */ |
||
| 29 | public function getHandler(): string |
||
| 30 | { |
||
| 31 | return $this->message->getHandler(); |
||
| 32 | } |
||
| 33 | |||
| 34 | 13 | public function getData(): mixed |
|
| 35 | { |
||
| 36 | 13 | return $this->message->getData(); |
|
| 37 | } |
||
| 38 | |||
| 39 | 2 | public static function fromMessage(MessageInterface $message): self |
|
| 40 | { |
||
| 41 | 2 | return new static($message); |
|
| 42 | } |
||
| 43 | |||
| 44 | 12 | public function getMetadata(): array |
|
| 45 | { |
||
| 46 | 12 | return array_merge( |
|
| 47 | 12 | $this->message->getMetadata(), |
|
| 48 | 12 | [ |
|
| 49 | 12 | self::ENVELOPE_STACK_KEY => array_merge( |
|
| 50 | 12 | $this->message->getMetadata()[self::ENVELOPE_STACK_KEY] ?? [], |
|
| 51 | 12 | [self::class], |
|
| 52 | 12 | ), |
|
| 53 | 12 | ], |
|
| 54 | 12 | $this->getEnvelopeMetadata(), |
|
| 55 | 12 | ); |
|
| 56 | } |
||
| 57 | |||
| 58 | public function getEnvelopeMetadata(): array |
||
| 59 | { |
||
| 60 | return []; |
||
| 61 | } |
||
| 62 | |||
| 63 | 1 | public function withData(mixed $data): self |
|
| 69 | } |
||
| 70 | |||
| 71 | public function withMetadata(array $metadata): self |
||
| 72 | { |
||
| 73 | $instance = clone $this; |
||
| 77 | } |
||
| 78 | |||
| 79 | public function withQueue(QueueInterface $queue): self |
||
| 80 | { |
||
| 87 |