Code Duplication    Length = 57-57 lines in 3 locations

src/Framing/Method/BasicAck.php 1 location

@@ 16-72 (lines=57) @@
13
 *
14
 * @codeCoverageIgnore
15
 */
16
class BasicAck extends Frame
17
{
18
    /**
19
     * @var int
20
     */
21
    private $deliveryTag;
22
23
    /**
24
     * @var bool
25
     */
26
    private $multiple;
27
28
    /**
29
     * @param int  $channel
30
     * @param int  $deliveryTag
31
     * @param bool $multiple
32
     */
33
    public function __construct($channel, $deliveryTag, $multiple)
34
    {
35
        $this->deliveryTag = $deliveryTag;
36
        $this->multiple = $multiple;
37
38
        parent::__construct($channel);
39
    }
40
41
    /**
42
     * DeliveryTag.
43
     *
44
     * @return int
45
     */
46
    public function getDeliveryTag()
47
    {
48
        return $this->deliveryTag;
49
    }
50
51
    /**
52
     * Acknowledge multiple messages.
53
     *
54
     * @return bool
55
     */
56
    public function isMultiple()
57
    {
58
        return $this->multiple;
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function encode()
65
    {
66
        $data = "\x00\x3C\x00\x50".
67
            Value\LongLongValue::encode($this->deliveryTag).
68
            Value\BooleanValue::encode($this->multiple);
69
70
        return "\x01".pack('nN', $this->channel, strlen($data)).$data."\xCE";
71
    }
72
}
73

src/Framing/Method/BasicCancel.php 1 location

@@ 16-72 (lines=57) @@
13
 *
14
 * @codeCoverageIgnore
15
 */
16
class BasicCancel extends Frame
17
{
18
    /**
19
     * @var string
20
     */
21
    private $consumerTag;
22
23
    /**
24
     * @var bool
25
     */
26
    private $noWait;
27
28
    /**
29
     * @param int    $channel
30
     * @param string $consumerTag
31
     * @param bool   $noWait
32
     */
33
    public function __construct($channel, $consumerTag, $noWait)
34
    {
35
        $this->consumerTag = $consumerTag;
36
        $this->noWait = $noWait;
37
38
        parent::__construct($channel);
39
    }
40
41
    /**
42
     * ConsumerTag.
43
     *
44
     * @return string
45
     */
46
    public function getConsumerTag()
47
    {
48
        return $this->consumerTag;
49
    }
50
51
    /**
52
     * NoWait.
53
     *
54
     * @return bool
55
     */
56
    public function isNoWait()
57
    {
58
        return $this->noWait;
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function encode()
65
    {
66
        $data = "\x00\x3C\x00\x1E".
67
            Value\ShortStringValue::encode($this->consumerTag).
68
            Value\BooleanValue::encode($this->noWait);
69
70
        return "\x01".pack('nN', $this->channel, strlen($data)).$data."\xCE";
71
    }
72
}
73

src/Framing/Method/BasicReject.php 1 location

@@ 16-72 (lines=57) @@
13
 *
14
 * @codeCoverageIgnore
15
 */
16
class BasicReject extends Frame
17
{
18
    /**
19
     * @var int
20
     */
21
    private $deliveryTag;
22
23
    /**
24
     * @var bool
25
     */
26
    private $requeue;
27
28
    /**
29
     * @param int  $channel
30
     * @param int  $deliveryTag
31
     * @param bool $requeue
32
     */
33
    public function __construct($channel, $deliveryTag, $requeue)
34
    {
35
        $this->deliveryTag = $deliveryTag;
36
        $this->requeue = $requeue;
37
38
        parent::__construct($channel);
39
    }
40
41
    /**
42
     * DeliveryTag.
43
     *
44
     * @return int
45
     */
46
    public function getDeliveryTag()
47
    {
48
        return $this->deliveryTag;
49
    }
50
51
    /**
52
     * Requeue the message.
53
     *
54
     * @return bool
55
     */
56
    public function isRequeue()
57
    {
58
        return $this->requeue;
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function encode()
65
    {
66
        $data = "\x00\x3C\x00\x5A".
67
            Value\LongLongValue::encode($this->deliveryTag).
68
            Value\BooleanValue::encode($this->requeue);
69
70
        return "\x01".pack('nN', $this->channel, strlen($data)).$data."\xCE";
71
    }
72
}
73