Total Complexity | 6 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | final class LightSwitchWasFlipped implements SerializablePayload |
||
10 | { |
||
11 | public const ON = true; |
||
12 | public const OFF = false; |
||
13 | |||
14 | /** |
||
15 | * @var bool |
||
16 | */ |
||
17 | private $state; |
||
18 | |||
19 | 4 | private function __construct(bool $state) |
|
20 | { |
||
21 | 4 | $this->state = $state; |
|
22 | 4 | } |
|
23 | |||
24 | 4 | public function state(): bool |
|
25 | { |
||
26 | 4 | return $this->state; |
|
27 | } |
||
28 | |||
29 | 4 | public static function on(): self |
|
30 | { |
||
31 | 4 | return new static(self::ON); |
|
32 | } |
||
33 | |||
34 | 2 | public static function off(): self |
|
37 | } |
||
38 | |||
39 | 4 | public function toPayload(): array |
|
42 | } |
||
43 | |||
44 | 4 | public static function fromPayload(array $payload): self |
|
47 | } |
||
48 | } |
||
49 |