Passed
Push — master ( 8634b9...ba407f )
by Chris
14:07
created

ProtocolHeader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
A getType() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace DaveRandom\LibLifxLan\Header;
4
5
use DaveRandom\LibLifxLan\Exceptions\InvalidValueException;
6
7
final class ProtocolHeader
8
{
9
    public const WIRE_SIZE = 12;
10
11
    private $type;
12
13
    /**
14
     * @param int $type
15
     * @throws InvalidValueException
16
     */
17 6
    public function __construct(int $type)
18
    {
19 6
        if ($type < 0 || $type > 65535) {
20 2
            throw new InvalidValueException("Message type {$type} outside allowable range of 0 - 65535");
21
        }
22
23 4
        $this->type = $type;
24
    }
25
26 1
    public function getType(): int
27
    {
28 1
        return $this->type;
29
    }
30
}
31