Completed
Pull Request — master (#1)
by Sergey
04:51
created

QueueDelete::encode()   A

Complexity

Conditions 4
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 1
nop 0
1
<?php
2
/*
3
 * This file is automatically generated.
4
 */
5
6
namespace ButterAMQP\AMQP091\Framing\Method;
7
8
use ButterAMQP\AMQP091\Framing\Frame;
9
use ButterAMQP\Value;
10
11
/**
12
 * Delete a queue.
13
 *
14
 * @codeCoverageIgnore
15
 */
16
class QueueDelete extends Frame
17
{
18
    /**
19
     * @var int
20
     */
21
    private $reserved1;
22
23
    /**
24
     * @var string
25
     */
26
    private $queue;
27
28
    /**
29
     * @var bool
30
     */
31
    private $ifUnused;
32
33
    /**
34
     * @var bool
35
     */
36
    private $ifEmpty;
37
38
    /**
39
     * @var bool
40
     */
41
    private $noWait;
42
43
    /**
44
     * @param int    $channel
45
     * @param int    $reserved1
46
     * @param string $queue
47
     * @param bool   $ifUnused
48
     * @param bool   $ifEmpty
49
     * @param bool   $noWait
50
     */
51
    public function __construct($channel, $reserved1, $queue, $ifUnused, $ifEmpty, $noWait)
52
    {
53
        $this->reserved1 = $reserved1;
54
        $this->queue = $queue;
55
        $this->ifUnused = $ifUnused;
56
        $this->ifEmpty = $ifEmpty;
57
        $this->noWait = $noWait;
58
59
        parent::__construct($channel);
60
    }
61
62
    /**
63
     * Reserved1.
64
     *
65
     * @return int
66
     */
67
    public function getReserved1()
68
    {
69
        return $this->reserved1;
70
    }
71
72
    /**
73
     * Queue.
74
     *
75
     * @return string
76
     */
77
    public function getQueue()
78
    {
79
        return $this->queue;
80
    }
81
82
    /**
83
     * Delete only if unused.
84
     *
85
     * @return bool
86
     */
87
    public function isIfUnused()
88
    {
89
        return $this->ifUnused;
90
    }
91
92
    /**
93
     * Delete only if empty.
94
     *
95
     * @return bool
96
     */
97
    public function isIfEmpty()
98
    {
99
        return $this->ifEmpty;
100
    }
101
102
    /**
103
     * NoWait.
104
     *
105
     * @return bool
106
     */
107
    public function isNoWait()
108
    {
109
        return $this->noWait;
110
    }
111
112
    /**
113
     * @return string
114
     */
115
    public function encode()
116
    {
117
        $data = "\x00\x32\x00\x28".
118
            Value\ShortValue::encode($this->reserved1).
119
            Value\ShortStringValue::encode($this->queue).
120
            Value\OctetValue::encode(($this->ifUnused ? 1 : 0) | (($this->ifEmpty ? 1 : 0) << 1) | (($this->noWait ? 1 : 0) << 2));
121
122
        return "\x01".pack('nN', $this->channel, strlen($data)).$data."\xCE";
123
    }
124
}
125