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

Header   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 82
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getClassId() 0 4 1
A getWeight() 0 4 1
A getSize() 0 4 1
A getProperties() 0 4 1
A encode() 0 7 1
1
<?php
2
3
namespace ButterAMQP\Framing;
4
5
/**
6
 * @codeCoverageIgnore
7
 */
8
class Header extends Frame
9
{
10
    /**
11
     * @var int
12
     */
13
    private $classId;
14
15
    /**
16
     * @var int
17
     */
18
    private $weight;
19
20
    /**
21
     * @var int
22
     */
23
    private $size;
24
25
    /**
26
     * @var array
27
     */
28
    private $properties = [];
29
30
    /**
31
     * @param int   $channel
32
     * @param int   $classId
33
     * @param int   $weight
34
     * @param int   $size
35
     * @param array $properties
36
     */
37
    public function __construct($channel, $classId, $weight, $size, array $properties = [])
38
    {
39
        $this->classId = $classId;
40
        $this->weight = $weight;
41
        $this->size = $size;
42
        $this->properties = $properties;
43
44
        parent::__construct($channel);
45
    }
46
47
    /**
48
     * @return int
49
     */
50
    public function getClassId()
51
    {
52
        return $this->classId;
53
    }
54
55
    /**
56
     * @return int
57
     */
58
    public function getWeight()
59
    {
60
        return $this->weight;
61
    }
62
63
    /**
64
     * @return int
65
     */
66
    public function getSize()
67
    {
68
        return $this->size;
69
    }
70
71
    /**
72
     * @return array
73
     */
74
    public function getProperties()
75
    {
76
        return $this->properties;
77
    }
78
79
    /**
80
     * @return string
81
     */
82
    public function encode()
83
    {
84
        $data = pack('nnJ', $this->classId, $this->weight, $this->size).
85
            Properties::encode($this->properties);
86
87
        return "\x02".pack('nN', $this->channel, strlen($data)).$data."\xCE";
88
    }
89
}
90