Completed
Pull Request — 0.4 (#35)
by jean
03:28
created

Message   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 68
ccs 0
cts 22
cp 0
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getProperties() 0 3 1
A __construct() 0 5 1
A getBody() 0 3 1
A getHeaders() 0 5 1
A getId() 0 3 1
1
<?php
2
3
namespace Darkilliant\MqProcessBundle\Message;
4
5
class Message
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $body;
11
12
    /**
13
     * Properties are similar to headers when using an \AMQPEnvelope object.
14
     *
15
     * @var array
16
     */
17
    protected $properties;
18
19
    /**
20
     * @var int
21
     */
22
    protected $id;
23
24
    /**
25
     * __construct.
26
     *
27
     * In AMQP 0.9.1, a message contains properties. One of this properties is
28
     * "headers".
29
     * In AMQP 1.0, a message contains both properties and headers.
30
     *
31
     * For example, RabbitMQ implement AMQP 0.9.1.
32
     * The "getHeaders" method of "\AMQPEnvelope" object actually return
33
     * message properties AND headers at the same level.
34
     * But if you want to have additional informations, you have to put it in
35
     * the "headers" property. All unknown properties will be deleted by the
36
     * broker.
37
     *
38
     * More information on AMQP version:
39
     *
40
     * @see: http://www.amqp.org/resources/download
41
     *
42
     * @param mixed $body
43
     * @param array $properties
44
     * @param mixed $id
45
     */
46
    public function __construct($body = null, array $properties = [], $id = null)
47
    {
48
        $this->body = $body;
49
        $this->properties = $properties;
50
        $this->id = $id;
51
    }
52
53
    public function getBody()
54
    {
55
        return $this->body;
56
    }
57
58
    public function getHeaders()
59
    {
60
        trigger_error('getHeaders() method is deprecated. Use getProperties().', E_USER_DEPRECATED);
61
62
        return $this->getProperties();
63
    }
64
65
    public function getProperties()
66
    {
67
        return $this->properties;
68
    }
69
70
    public function getId()
71
    {
72
        return $this->id;
73
    }
74
}
75