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

ChannelClose::encode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
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
 * Request a channel close.
13
 *
14
 * @codeCoverageIgnore
15
 */
16 View Code Duplication
class ChannelClose extends Frame
0 ignored issues
show
Duplication introduced by
This class 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...
17
{
18
    /**
19
     * @var int
20
     */
21
    private $replyCode;
22
23
    /**
24
     * @var string
25
     */
26
    private $replyText;
27
28
    /**
29
     * @var int
30
     */
31
    private $classId;
32
33
    /**
34
     * @var int
35
     */
36
    private $methodId;
37
38
    /**
39
     * @param int    $channel
40
     * @param int    $replyCode
41
     * @param string $replyText
42
     * @param int    $classId
43
     * @param int    $methodId
44
     */
45
    public function __construct($channel, $replyCode, $replyText, $classId, $methodId)
46
    {
47
        $this->replyCode = $replyCode;
48
        $this->replyText = $replyText;
49
        $this->classId = $classId;
50
        $this->methodId = $methodId;
51
52
        parent::__construct($channel);
53
    }
54
55
    /**
56
     * ReplyCode.
57
     *
58
     * @return int
59
     */
60
    public function getReplyCode()
61
    {
62
        return $this->replyCode;
63
    }
64
65
    /**
66
     * ReplyText.
67
     *
68
     * @return string
69
     */
70
    public function getReplyText()
71
    {
72
        return $this->replyText;
73
    }
74
75
    /**
76
     * Failing method class.
77
     *
78
     * @return int
79
     */
80
    public function getClassId()
81
    {
82
        return $this->classId;
83
    }
84
85
    /**
86
     * Failing method ID.
87
     *
88
     * @return int
89
     */
90
    public function getMethodId()
91
    {
92
        return $this->methodId;
93
    }
94
95
    /**
96
     * @return string
97
     */
98
    public function encode()
99
    {
100
        $data = "\x00\x14\x00\x28".
101
            Value\ShortValue::encode($this->replyCode).
102
            Value\ShortStringValue::encode($this->replyText).
103
            Value\ShortValue::encode($this->classId).
104
            Value\ShortValue::encode($this->methodId);
105
106
        return "\x01".pack('nN', $this->channel, strlen($data)).$data."\xCE";
107
    }
108
}
109