Completed
Push — master ( 9b90e7...a2b649 )
by John
17:01 queued 14:42
created

AMQPMessage::getContentEncoding()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
namespace PhpAmqpLib\Message;
3
4
use PhpAmqpLib\Wire\GenericContent;
5
6
/**
7
 * A Message for use with the Channnel.basic_* methods.
8
 */
9
class AMQPMessage extends GenericContent
10
{
11
    const DELIVERY_MODE_NON_PERSISTENT = 1;
12
    const DELIVERY_MODE_PERSISTENT = 2;
13
14
    /** @var string */
15
    public $body;
16
17
    /** @var int */
18
    public $body_size;
19
20
    /** @var bool */
21
    public $is_truncated = false;
22
23
    /** @var string */
24
    public $content_encoding;
25
26
    /** @var array */
27
    protected static $propertyDefinitions = array(
28
        'content_type' => 'shortstr',
29
        'content_encoding' => 'shortstr',
30
        'application_headers' => 'table_object',
31
        'delivery_mode' => 'octet',
32
        'priority' => 'octet',
33
        'correlation_id' => 'shortstr',
34
        'reply_to' => 'shortstr',
35
        'expiration' => 'shortstr',
36
        'message_id' => 'shortstr',
37
        'timestamp' => 'timestamp',
38
        'type' => 'shortstr',
39
        'user_id' => 'shortstr',
40
        'app_id' => 'shortstr',
41
        'cluster_id' => 'shortstr',
42
    );
43
44
    /**
45
     * @param string $body
46
     * @param array $properties
47
     */
48 132
    public function __construct($body = '', $properties = array())
49
    {
50 132
        $this->setBody($body);
51 132
        parent::__construct($properties, static::$propertyDefinitions);
52 132
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getBody()
58
    {
59
        return $this->body;
60
    }
61
62
    /**
63
     * Sets the message payload
64
     *
65
     * @param string $body
66
     * @return $this
67
     */
68 132
    public function setBody($body)
69
    {
70 132
        $this->body = $body;
71
72 132
        return $this;
73
    }
74
75
    /**
76
     * @return string
77
     */
78
    public function getContentEncoding()
79
    {
80
        return $this->content_encoding;
81
    }
82
83
    /**
84
     * @return int
85
     */
86 42
    public function getBodySize()
87
    {
88 42
        return $this->body_size;
89
    }
90
91
    /**
92
     * @param int $body_size Message body size in byte(s)
93
     * @return AMQPMessage
94
     */
95 42
    public function setBodySize($body_size)
96
    {
97 42
        $this->body_size = (int) $body_size;
98
99 42
        return $this;
100
    }
101
102
    /**
103
     * @return boolean
104
     */
105
    public function isTruncated()
106
    {
107
        return $this->is_truncated;
108
    }
109
110
    /**
111
     * @param boolean $is_truncated
112
     * @return AMQPMessage
113
     */
114
    public function setIsTruncated($is_truncated)
115
    {
116
        $this->is_truncated = (bool) $is_truncated;
117
118
        return $this;
119
    }
120
}
121