Total Complexity | 5 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class Header |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | private $command; |
||
15 | |||
16 | /** |
||
17 | * @var int |
||
18 | */ |
||
19 | private $length; |
||
20 | |||
21 | /** |
||
22 | * @var BufferInterface |
||
23 | */ |
||
24 | private $checksum; |
||
25 | |||
26 | /** |
||
27 | * Header constructor. |
||
28 | * @param string $command |
||
29 | * @param int $length |
||
30 | * @param BufferInterface $checksum |
||
31 | */ |
||
32 | public function __construct(string $command, int $length, BufferInterface $checksum) |
||
33 | { |
||
34 | if ($checksum->getSize() != 4) { |
||
35 | throw new \InvalidArgumentException("Checksum has invalid length"); |
||
36 | } |
||
37 | |||
38 | $this->command = $command; |
||
39 | $this->length = $length; |
||
40 | $this->checksum = $checksum; |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @return string |
||
45 | */ |
||
46 | public function getCommand(): string |
||
47 | { |
||
48 | return $this->command; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return BufferInterface |
||
53 | */ |
||
54 | public function getChecksum(): BufferInterface |
||
55 | { |
||
56 | return $this->checksum; |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * @return int |
||
61 | */ |
||
62 | public function getLength(): int |
||
65 | } |
||
66 | } |
||
67 |