Completed
Push — master ( 42bf17...fdb7de )
by Sergey
04:25
created

BasicNack::decode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
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
 * Reject one or more incoming messages.
13
 *
14
 * @codeCoverageIgnore
15
 */
16
class BasicNack extends Frame
17
{
18
    /**
19
     * @var int
20
     */
21
    private $deliveryTag;
22
23
    /**
24
     * @var bool
25
     */
26
    private $multiple;
27
28
    /**
29
     * @var bool
30
     */
31
    private $requeue;
32
33
    /**
34
     * @param int  $channel
35
     * @param int  $deliveryTag
36
     * @param bool $multiple
37
     * @param bool $requeue
38
     */
39
    public function __construct($channel, $deliveryTag, $multiple, $requeue)
40
    {
41
        $this->deliveryTag = $deliveryTag;
42
        $this->multiple = $multiple;
43
        $this->requeue = $requeue;
44
45
        parent::__construct($channel);
46
    }
47
48
    /**
49
     * DeliveryTag.
50
     *
51
     * @return int
52
     */
53
    public function getDeliveryTag()
54
    {
55
        return $this->deliveryTag;
56
    }
57
58
    /**
59
     * Reject multiple messages.
60
     *
61
     * @return bool
62
     */
63
    public function isMultiple()
64
    {
65
        return $this->multiple;
66
    }
67
68
    /**
69
     * Requeue the message.
70
     *
71
     * @return bool
72
     */
73
    public function isRequeue()
74
    {
75
        return $this->requeue;
76
    }
77
78
    /**
79
     * @return string
80
     */
81
    public function encode()
82
    {
83
        $data = "\x00\x3C\x00\x78".
84
            Value\LongLongValue::encode($this->deliveryTag).
85
            Value\OctetValue::encode(($this->multiple ? 1 : 0) | (($this->requeue ? 1 : 0) << 1));
86
87
        return "\x01".pack('nN', $this->channel, strlen($data)).$data."\xCE";
88
    }
89
}
90