Completed
Push — master ( fdb7de...e17409 )
by Sergey
03:32
created

QueuePurge   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 75
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 4
dl 75
loc 75
rs 10

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
 * Purge a queue.
13
 *
14
 * @codeCoverageIgnore
15
 */
16
class QueuePurge 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 $noWait;
32
33
    /**
34
     * @param int    $channel
35
     * @param int    $reserved1
36
     * @param string $queue
37
     * @param bool   $noWait
38
     */
39
    public function __construct($channel, $reserved1, $queue, $noWait)
40
    {
41
        $this->reserved1 = $reserved1;
42
        $this->queue = $queue;
43
        $this->noWait = $noWait;
44
45
        parent::__construct($channel);
46
    }
47
48
    /**
49
     * Reserved1.
50
     *
51
     * @return int
52
     */
53
    public function getReserved1()
54
    {
55
        return $this->reserved1;
56
    }
57
58
    /**
59
     * Queue.
60
     *
61
     * @return string
62
     */
63
    public function getQueue()
64
    {
65
        return $this->queue;
66
    }
67
68
    /**
69
     * NoWait.
70
     *
71
     * @return bool
72
     */
73
    public function isNoWait()
74
    {
75
        return $this->noWait;
76
    }
77
78
    /**
79
     * @return string
80
     */
81
    public function encode()
82
    {
83
        $data = "\x00\x32\x00\x1E".
84
            Value\ShortValue::encode($this->reserved1).
85
            Value\ShortStringValue::encode($this->queue).
86
            Value\BooleanValue::encode($this->noWait);
87
88
        return "\x01".pack('nN', $this->channel, strlen($data)).$data."\xCE";
89
    }
90
}
91