Test Failed
Pull Request — master (#188)
by Dmitriy
02:40
created

EnvelopeTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 41
ccs 4
cts 12
cp 0.3333
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 8 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
    public function getMessage(): MessageInterface
12
    {
13
        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 7
    public function getHandlerName(): string
25
    {
26 7
        return $this->message->getHandlerName();
27
    }
28
29 1
    public function getData(): mixed
30
    {
31 1
        return $this->message->getData();
32
    }
33
34
    public function getMetadata(): array
35
    {
36
        return array_merge($this->message->getMetadata(), [
37
            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...
38
                $this->message->getMetadata()[self::ENVELOPE_STACK_KEY] ?? [],
39
                [self::class],
40
            ),
41
            ...$this->getEnvelopeMetadata(),
42
        ]);
43
    }
44
45
    public function getEnvelopeMetadata(): array
46
    {
47
        return [];
48
    }
49
}
50