Completed
Push — master ( 0d7a8a...2e892a )
by Chris
03:11
created

PowerTransition::setLevel()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 3
rs 9.4285
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A PowerTransition::__construct() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace DaveRandom\LibLifxLan\DataTypes\Light;
4
5
use DaveRandom\LibLifxLan\Exceptions\InvalidValueException;
6
use function DaveRandom\LibLifxLan\validate_uint16;
7
use function DaveRandom\LibLifxLan\validate_uint32;
8
9
final class PowerTransition
10
{
11
    private $level;
12
    private $duration;
13
14
    /**
15
     * @param int $level
16
     * @param int $duration
17
     * @throws InvalidValueException
18
     */
19 9
    public function __construct(int $level, int $duration)
20
    {
21 9
        $this->level = validate_uint16('Power level', $level);
22 7
        $this->duration = validate_uint32('Transition duration', $duration);
23
    }
24
25 1
    public function getLevel(): int
26
    {
27 1
        return $this->level;
28
    }
29
30 1
    public function getDuration(): int
31
    {
32 1
        return $this->duration;
33
    }
34
}
35