Lines
75.00%
3 / 4
Functions and Methods
75.00%
3 / 4
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| SwitchCommand | 75.00% | 3 / 4 | 75.00% | 3 / 4 | 4.25 | 0.00% | 0 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| isTurnOn | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| getContext | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| getRequestedState | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Contracts\Exposure\Command; | |
| 6 | ||
| 7 | use Stewart\Contracts\Exposure\ExposedState; | |
| 8 | use Stewart\Contracts\State\EventContext; | |
| 9 | ||
| 10 | final readonly class SwitchCommand implements ExposedCommand | |
| 11 | { | |
| 12 | public function __construct( | |
| 13 | public SwitchAction $action, | |
| 14 | public EventContext $context, | |
| 15 | ) {} | |
| 16 | ||
| 17 | public function isTurnOn(): bool | |
| 18 | { | |
| 19 | return $this->action === SwitchAction::TurnOn; | |
| 20 | } | |
| 21 | ||
| 22 | public function getContext(): EventContext | |
| 23 | { | |
| 24 | return $this->context; | |
| 25 | } | |
| 26 | ||
| 27 | public function getRequestedState(): ExposedState | |
| 28 | { | |
| 29 | return new ExposedState($this->isTurnOn()); | |
| 30 | } | |
| 31 | } |