Completed
Push — master ( 743e55...688ce0 )
by Cody
02:20
created

QueuedMessage   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 54
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getQueueName() 0 4 1
A getDeliveryTag() 0 4 1
A getBody() 0 4 1
A getRawBody() 0 4 1
A __get() 0 4 1
1
<?php
2
3
namespace Ccovey\RabbitMQ;
4
5
use PhpAmqpLib\Channel\AMQPChannel;
6
use PhpAmqpLib\Message\AMQPMessage;
7
8
class QueuedMessage implements QueuedMessageInterface
9
{
10
    /**
11
     * @var AMQPMessage
12
     */
13
    private $message;
14
15
    /**
16
     * @var array
17
     */
18
    private $body;
19
20
    /**
21
     * @var AMQPChannel
22
     */
23
    private $queueName;
24
25 2
    public function __construct(AMQPMessage $message)
26
    {
27 2
        $this->message = $message;
28 2
        $this->body = json_decode($this->message->body, 1);
29 2
        $this->queueName = $this->message->delivery_info['routing_key'];
30 2
    }
31
32 1
    public function getQueueName() : string
33
    {
34 1
        return $this->queueName;
35
    }
36
37 1
    public function getDeliveryTag() : string
38
    {
39 1
        return $this->message->delivery_info['delivery_tag'];
40
    }
41
42 2
    public function getBody() : array
43
    {
44 2
        return $this->body;
45
    }
46
47
    public function getRawBody() : string
48
    {
49
        return $this->message->body;
50
    }
51
52
    /**
53
     * @param string $value
54
     *
55
     * @return mixed|null
56
     */
57 1
    public function __get(string $value)
58
    {
59 1
        return $this->body[$value] ?? null;
60
    }
61
}
62