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

Message::getBody()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
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