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

BasicQos::decode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 8
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
 * Specify quality of service.
13
 *
14
 * @codeCoverageIgnore
15
 */
16 View Code Duplication
class BasicQos 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 $prefetchSize;
22
23
    /**
24
     * @var int
25
     */
26
    private $prefetchCount;
27
28
    /**
29
     * @var bool
30
     */
31
    private $global;
32
33
    /**
34
     * @param int  $channel
35
     * @param int  $prefetchSize
36
     * @param int  $prefetchCount
37
     * @param bool $global
38
     */
39
    public function __construct($channel, $prefetchSize, $prefetchCount, $global)
40
    {
41
        $this->prefetchSize = $prefetchSize;
42
        $this->prefetchCount = $prefetchCount;
43
        $this->global = $global;
44
45
        parent::__construct($channel);
46
    }
47
48
    /**
49
     * Prefetch window in octets.
50
     *
51
     * @return int
52
     */
53
    public function getPrefetchSize()
54
    {
55
        return $this->prefetchSize;
56
    }
57
58
    /**
59
     * Prefetch window in messages.
60
     *
61
     * @return int
62
     */
63
    public function getPrefetchCount()
64
    {
65
        return $this->prefetchCount;
66
    }
67
68
    /**
69
     * Apply to entire connection.
70
     *
71
     * @return bool
72
     */
73
    public function isGlobal()
74
    {
75
        return $this->global;
76
    }
77
78
    /**
79
     * @return string
80
     */
81
    public function encode()
82
    {
83
        $data = "\x00\x3C\x00\x0A".
84
            Value\LongValue::encode($this->prefetchSize).
85
            Value\ShortValue::encode($this->prefetchCount).
86
            Value\BooleanValue::encode($this->global);
87
88
        return "\x01".pack('nN', $this->channel, strlen($data)).$data."\xCE";
89
    }
90
}
91