Passed
Pull Request — master (#190)
by Dmitriy
03:56
created

MessageTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 27
ccs 12
cts 12
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 3 1
A withData() 0 5 1
A getMetadata() 0 3 1
A withMetadata() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Queue\Message;
6
7
trait MessageTrait
8
{
9
    private mixed $data = [];
10
    private array $metadata = [];
11
12 53
    public function getData(): mixed
13
    {
14 53
        return $this->data;
15
    }
16
17 8
    public function withData(mixed $data): self
18
    {
19 8
        $new = clone $this;
20 8
        $new->data = $data;
21 8
        return $new;
22
    }
23
24 38
    public function getMetadata(): array
25
    {
26 38
        return $this->metadata;
27
    }
28
29 5
    public function withMetadata(array $metadata): self
30
    {
31 5
        $new = clone $this;
32 5
        $new->metadata = $metadata;
33 5
        return $new;
34
    }
35
}
36