EnvelopeTrait   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 73.91%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 44
ccs 17
cts 23
cp 0.7391
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A withMessage() 0 6 1
A getData() 0 3 1
A getHandlerName() 0 3 1
A getMessage() 0 3 1
A getMetadata() 0 11 1
A getEnvelopeMetadata() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Queue\Message;
6
7
trait EnvelopeTrait
8
{
9
    private MessageInterface $message;
10
11 4
    public function getMessage(): MessageInterface
12
    {
13 4
        return $this->message;
14
    }
15
16
    public function withMessage(MessageInterface $message): self
17
    {
18
        $instance = clone $this;
19
        $instance->message = $message;
20
21
        return $instance;
22
    }
23
24 8
    public function getHandlerName(): string
25
    {
26 8
        return $this->message->getHandlerName();
27
    }
28
29 4
    public function getData(): mixed
30
    {
31 4
        return $this->message->getData();
32
    }
33
34 12
    public function getMetadata(): array
35
    {
36 12
        return array_merge(
37 12
            $this->message->getMetadata(),
38 12
            [
39 12
                self::ENVELOPE_STACK_KEY => array_merge(
0 ignored issues
show
Bug introduced by
The constant Yiisoft\Queue\Message\En...ait::ENVELOPE_STACK_KEY was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
40 12
                    $this->message->getMetadata()[self::ENVELOPE_STACK_KEY] ?? [],
41 12
                    [self::class],
42 12
                ),
43 12
            ],
44 12
            $this->getEnvelopeMetadata(),
45 12
        );
46
    }
47
48
    public function getEnvelopeMetadata(): array
49
    {
50
        return [];
51
    }
52
}
53