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

BasicPublish::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 6
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
 * Publish a message.
13
 *
14
 * @codeCoverageIgnore
15
 */
16
class BasicPublish extends Frame
17
{
18
    /**
19
     * @var int
20
     */
21
    private $reserved1;
22
23
    /**
24
     * @var string
25
     */
26
    private $exchange;
27
28
    /**
29
     * @var string
30
     */
31
    private $routingKey;
32
33
    /**
34
     * @var bool
35
     */
36
    private $mandatory;
37
38
    /**
39
     * @var bool
40
     */
41
    private $immediate;
42
43
    /**
44
     * @param int    $channel
45
     * @param int    $reserved1
46
     * @param string $exchange
47
     * @param string $routingKey
48
     * @param bool   $mandatory
49
     * @param bool   $immediate
50
     */
51
    public function __construct($channel, $reserved1, $exchange, $routingKey, $mandatory, $immediate)
52
    {
53
        $this->reserved1 = $reserved1;
54
        $this->exchange = $exchange;
55
        $this->routingKey = $routingKey;
56
        $this->mandatory = $mandatory;
57
        $this->immediate = $immediate;
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
     * Exchange.
74
     *
75
     * @return string
76
     */
77
    public function getExchange()
78
    {
79
        return $this->exchange;
80
    }
81
82
    /**
83
     * Message routing key.
84
     *
85
     * @return string
86
     */
87
    public function getRoutingKey()
88
    {
89
        return $this->routingKey;
90
    }
91
92
    /**
93
     * Indicate mandatory routing.
94
     *
95
     * @return bool
96
     */
97
    public function isMandatory()
98
    {
99
        return $this->mandatory;
100
    }
101
102
    /**
103
     * Request immediate delivery.
104
     *
105
     * @return bool
106
     */
107
    public function isImmediate()
108
    {
109
        return $this->immediate;
110
    }
111
112
    /**
113
     * @return string
114
     */
115 View Code Duplication
    public function encode()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
116
    {
117
        $data = "\x00\x3C\x00\x28".
118
            Value\ShortValue::encode($this->reserved1).
119
            Value\ShortStringValue::encode($this->exchange).
120
            Value\ShortStringValue::encode($this->routingKey).
121
            Value\OctetValue::encode(($this->mandatory ? 1 : 0) | (($this->immediate ? 1 : 0) << 1));
122
123
        return "\x01".pack('nN', $this->channel, strlen($data)).$data."\xCE";
124
    }
125
}
126