Completed
Push — master ( fdb7de...e17409 )
by Sergey
03:32
created

BasicDeliver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
nc 1
nop 6
1
<?php
2
/*
3
 * This file is automatically generated.
4
 */
5
6
namespace ButterAMQP\Framing\Method;
7
8
use ButterAMQP\Framing\Frame;
9
use ButterAMQP\Value;
10
11
/**
12
 * Notify the client of a consumer message.
13
 *
14
 * @codeCoverageIgnore
15
 */
16
class BasicDeliver extends Frame
17
{
18
    /**
19
     * @var string
20
     */
21
    private $consumerTag;
22
23
    /**
24
     * @var int
25
     */
26
    private $deliveryTag;
27
28
    /**
29
     * @var bool
30
     */
31
    private $redelivered;
32
33
    /**
34
     * @var string
35
     */
36
    private $exchange;
37
38
    /**
39
     * @var string
40
     */
41
    private $routingKey;
42
43
    /**
44
     * @param int    $channel
45
     * @param string $consumerTag
46
     * @param int    $deliveryTag
47
     * @param bool   $redelivered
48
     * @param string $exchange
49
     * @param string $routingKey
50
     */
51
    public function __construct($channel, $consumerTag, $deliveryTag, $redelivered, $exchange, $routingKey)
52
    {
53
        $this->consumerTag = $consumerTag;
54
        $this->deliveryTag = $deliveryTag;
55
        $this->redelivered = $redelivered;
56
        $this->exchange = $exchange;
57
        $this->routingKey = $routingKey;
58
59
        parent::__construct($channel);
60
    }
61
62
    /**
63
     * ConsumerTag.
64
     *
65
     * @return string
66
     */
67
    public function getConsumerTag()
68
    {
69
        return $this->consumerTag;
70
    }
71
72
    /**
73
     * DeliveryTag.
74
     *
75
     * @return int
76
     */
77
    public function getDeliveryTag()
78
    {
79
        return $this->deliveryTag;
80
    }
81
82
    /**
83
     * Redelivered.
84
     *
85
     * @return bool
86
     */
87
    public function isRedelivered()
88
    {
89
        return $this->redelivered;
90
    }
91
92
    /**
93
     * Exchange.
94
     *
95
     * @return string
96
     */
97
    public function getExchange()
98
    {
99
        return $this->exchange;
100
    }
101
102
    /**
103
     * Message routing key.
104
     *
105
     * @return string
106
     */
107
    public function getRoutingKey()
108
    {
109
        return $this->routingKey;
110
    }
111
112
    /**
113
     * @return string
114
     */
115
    public function encode()
116
    {
117
        $data = "\x00\x3C\x00\x3C".
118
            Value\ShortStringValue::encode($this->consumerTag).
119
            Value\LongLongValue::encode($this->deliveryTag).
120
            Value\BooleanValue::encode($this->redelivered).
121
            Value\ShortStringValue::encode($this->exchange).
122
            Value\ShortStringValue::encode($this->routingKey);
123
124
        return "\x01".pack('nN', $this->channel, strlen($data)).$data."\xCE";
125
    }
126
}
127