Firmware::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace DaveRandom\LibLifxLan\DataTypes;
4
5
use DaveRandom\LibLifxLan\Exceptions\InvalidValueException;
6
use function DaveRandom\LibLifxLan\datetimeinterface_to_datetimeimmutable;
7
use function DaveRandom\LibLifxLan\validate_uint32;
8
9
abstract class Firmware
10
{
11
    private $build;
12
    private $version;
13
14
    /**
15
     * @param \DateTimeInterface $build
16
     * @param int $version
17
     * @throws InvalidValueException
18
     */
19 22
    protected function __construct(\DateTimeInterface $build, int $version)
20
    {
21 22
        $this->build = datetimeinterface_to_datetimeimmutable($build);
22 22
        $this->version = validate_uint32('Firmware version', $version);
23
    }
24
25 7
    public function getBuild(): \DateTimeImmutable
26
    {
27 7
        return $this->build;
28
    }
29
30 7
    public function getVersion(): int
31
    {
32 7
        return $this->version;
33
    }
34
}
35