Message   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 88
ccs 19
cts 19
cp 1
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A age() 0 3 1
A queue() 0 3 1
A headers() 0 3 1
A jsonSerialize() 0 7 1
A body() 0 3 1
A __construct() 0 10 1
1
<?php
2
3
namespace ZoiloMora\ElasticAPM\Events\Common;
4
5
use ZoiloMora\ElasticAPM\Events\Common\Message\Age;
6
use ZoiloMora\ElasticAPM\Events\Common\Message\Queue;
7
8
/**
9
 * Details related to message receiving and publishing if the captured event integrates with a messaging system
10
 */
11
class Message implements \JsonSerializable
12
{
13
    /**
14
     * Name of the message queue where the message is received.
15
     *
16
     * @var Queue
17
     */
18
    private $queue;
19
20
    /**
21
     * @var Age|null
22
     */
23
    private $age;
24
25
    /**
26
     * messsage body, similar to an http request body
27
     *
28
     * @var string|null
29
     */
30
    private $body;
31
32
    /**
33
     * messsage headers, similar to http request headers
34
     *
35
     * @var array|null
36
     */
37
    private $headers;
38
39
    /**
40
     * @param Queue $queue
41
     * @param Age|null $age
42
     * @param string|null $body
43
     * @param array|null $headers
44
     */
45 2
    public function __construct(
46
        Queue $queue,
47
        Age $age = null,
48
        $body = null,
49
        array $headers = null
50
    ) {
51 2
        $this->queue = $queue;
52 2
        $this->age = $age;
53 2
        $this->body = $body;
54 2
        $this->headers = $headers;
55 2
    }
56
57
    /**
58
     * @return Queue
59
     */
60 1
    public function queue()
61
    {
62 1
        return $this->queue;
63
    }
64
65
    /**
66
     * @return Age|null
67
     */
68 1
    public function age()
69
    {
70 1
        return $this->age;
71
    }
72
73
    /**
74
     * @return string|null
75
     */
76 1
    public function body()
77
    {
78 1
        return $this->body;
79
    }
80
81
    /**
82
     * @return array|null
83
     */
84 1
    public function headers()
85
    {
86 1
        return $this->headers;
87
    }
88
89
    /**
90
     * @return array
91
     */
92 1
    public function jsonSerialize()
93
    {
94
        return [
95 1
            'queue' => $this->queue,
96 1
            'age' => $this->age,
97 1
            'body' => $this->body,
98 1
            'headers' => $this->headers,
99 1
        ];
100
    }
101
}
102