EchoRequest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPayload() 0 3 1
A __construct() 0 7 2
A getWireSize() 0 3 1
A getTypeId() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace DaveRandom\LibLifxLan\Messages\Device\Requests;
4
5
use DaveRandom\LibLifxLan\Exceptions\InvalidValueException;
6
use DaveRandom\LibLifxLan\Messages\Message;
7
8
final class EchoRequest implements Message
9
{
10
    public const MESSAGE_TYPE_ID = 58;
11
    public const WIRE_SIZE = 64;
12
13
    private $payload;
14
15
    /**
16
     * @param string $payload
17
     * @throws InvalidValueException
18
     */
19 7
    public function __construct(string $payload)
20
    {
21 7
        if (\strlen($payload) !== 64) {
22 2
            throw new InvalidValueException("Echo request payload should be exactly 64 bytes");
23
        }
24
25 5
        $this->payload = $payload;
26
    }
27
28 3
    public function getPayload(): string
29
    {
30 3
        return $this->payload;
31
    }
32
33 1
    public function getTypeId(): int
34
    {
35 1
        return self::MESSAGE_TYPE_ID;
36
    }
37
38 1
    public function getWireSize(): int
39
    {
40 1
        return self::WIRE_SIZE;
41
    }
42
}
43