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

Effect::isTransient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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_int16;
7
use function DaveRandom\LibLifxLan\validate_uint32;
8
use function DaveRandom\LibLifxLan\validate_uint8;
9
10
final class Effect
11
{
12
    public const SET_HUE         = 0b0001;
13
    public const SET_SATURATION  = 0b0010;
14
    public const SET_BRIGHTNESS  = 0b0100;
15
    public const SET_TEMPERATURE = 0b1000;
16
    public const SET_ALL = self::SET_HUE | self::SET_SATURATION | self::SET_BRIGHTNESS | self::SET_TEMPERATURE;
17
18
    private $transient;
19
    private $color;
20
    private $period;
21
    private $cycles;
22
    private $skewRatio;
23
    private $waveform;
24
    private $options;
25
26
    /**
27
     * @param bool $transient
28
     * @param HsbkColor $color
29
     * @param int $period
30
     * @param float $cycles
31
     * @param int $skewRatio
32
     * @param int $waveform
33
     * @param int $options
34
     * @throws InvalidValueException
35
     */
36 20
    public function __construct(
37
        bool $transient,
38
        HsbkColor $color,
39
        int $period,
40
        float $cycles,
41
        int $skewRatio,
42
        int $waveform,
43
        int $options = self::SET_ALL
44
    ) {
45 20
        $this->transient = $transient;
46 20
        $this->color = $color;
47 20
        $this->period = validate_uint32('Period', $period);
48 18
        $this->cycles = $cycles;
49 18
        $this->skewRatio = validate_int16('Skew ratio', $skewRatio);
50 16
        $this->waveform = validate_uint8('Waveform', $waveform);
51 14
        $this->options = $options;
52
    }
53
54 1
    public function isTransient(): bool
55
    {
56 1
        return $this->transient;
57
    }
58
59 1
    public function getColor(): HsbkColor
60
    {
61 1
        return $this->color;
62
    }
63
64 1
    public function getPeriod(): int
65
    {
66 1
        return $this->period;
67
    }
68
69 1
    public function getCycles(): float
70
    {
71 1
        return $this->cycles;
72
    }
73
74 1
    public function getSkewRatio(): int
75
    {
76 1
        return $this->skewRatio;
77
    }
78
79 1
    public function getWaveform(): int
80
    {
81 1
        return $this->waveform;
82
    }
83
84 1
    public function getOptions(): int
85
    {
86 1
        return $this->options;
87
    }
88
89 1
    public function hasOption(int $option): bool
90
    {
91 1
        return (bool)($this->options & $option);
92
    }
93
}
94