Passed
Push — master ( 5339df...fb5d3c )
by Alexander
03:17
created

IdEnvelope::getEnvelopeMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Queue\Message;
6
7
/**
8
 * ID envelope allows to identify a message.
9
 */
10
final class IdEnvelope implements EnvelopeInterface
11
{
12
    use EnvelopeTrait;
13
14
    public const MESSAGE_ID_KEY = 'yii-message-id';
15
16 13
    public function __construct(
17
        private MessageInterface $message,
18
        private string|int|null $id = null,
19
    ) {
20 13
    }
21
22
    public function setId(string|int|null $id): void
23
    {
24
        $this->id = $id;
25
    }
26
27 12
    public function getId(): string|int|null
28
    {
29 12
        return $this->id ?? $this->message->getMetadata()[self::MESSAGE_ID_KEY] ?? null;
30
    }
31
32 12
    private function getEnvelopeMetadata(): array
0 ignored issues
show
Unused Code introduced by
The method getEnvelopeMetadata() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
33
    {
34 12
        return [self::MESSAGE_ID_KEY => $this->getId()];
35
    }
36
}
37