FrameAddress   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 42
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getTarget() 0 3 1
A isAckRequired() 0 3 1
A getSequenceNo() 0 3 1
A isResponseRequired() 0 3 1
A __construct() 0 6 1
1
<?php declare(strict_types=1);
2
3
namespace DaveRandom\LibLifxLan\Header;
4
5
use DaveRandom\LibLifxLan\Exceptions\InvalidValueException;
6
use DaveRandom\Network\MacAddress;
7
use function DaveRandom\LibLifxLan\validate_uint8;
8
9
final class FrameAddress
10
{
11
    public const WIRE_SIZE = 16;
12
13
    private $target;
14
    private $ackRequired;
15
    private $responseRequired;
16
    private $sequenceNo;
17
18
    /**
19
     * @param MacAddress $target
20
     * @param bool $ackRequired
21
     * @param bool $responseRequired
22
     * @param int $sequenceNo
23
     * @throws InvalidValueException
24
     */
25 40
    public function __construct(MacAddress $target, bool $ackRequired, bool $responseRequired, int $sequenceNo)
26
    {
27 40
        $this->target = $target;
28 40
        $this->ackRequired = $ackRequired;
29 40
        $this->responseRequired = $responseRequired;
30 40
        $this->sequenceNo = validate_uint8('Sequence number', $sequenceNo);
31
    }
32
33 22
    public function getTarget(): MacAddress
34
    {
35 22
        return $this->target;
36
    }
37
38 21
    public function isAckRequired(): bool
39
    {
40 21
        return $this->ackRequired;
41
    }
42
43 21
    public function isResponseRequired(): bool
44
    {
45 21
        return $this->responseRequired;
46
    }
47
48 21
    public function getSequenceNo(): int
49
    {
50 21
        return $this->sequenceNo;
51
    }
52
}
53