Lines
60.00%
3 / 5
Functions and Methods
60.00%
3 / 5
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| RecordingExposedButton | 60.00% | 3 / 5 | 60.00% | 3 / 5 | 6.60 | 0.00% | 0 / 1 | |||
| getConfig | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| updateConfig | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| watchCommands | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| pushCommand | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| pushPress | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Testing\Exposure; | |
| 6 | ||
| 7 | use Stewart\Contracts\EventStream; | |
| 8 | use Stewart\Contracts\Exception\CommandException; | |
| 9 | use Stewart\Contracts\Exposure\ButtonConfig; | |
| 10 | use Stewart\Contracts\Exposure\Command\ButtonPress; | |
| 11 | use Stewart\Contracts\Exposure\ExposedButton; | |
| 12 | use Stewart\Contracts\State\EventContext; | |
| 13 | ||
| 14 | /** @extends RecordingExposedEntity<ButtonConfig> */ | |
| 15 | final class RecordingExposedButton extends RecordingExposedEntity implements ExposedButton | |
| 16 | { | |
| 17 | public function getConfig(): ButtonConfig | |
| 18 | { | |
| 19 | return $this->config; | |
| 20 | } | |
| 21 | ||
| 22 | public function updateConfig(ButtonConfig $config): void | |
| 23 | { | |
| 24 | $this->recordConfig($config); | |
| 25 | } | |
| 26 | ||
| 27 | public function watchCommands(): EventStream | |
| 28 | { | |
| 29 | /** @var EventStream<ButtonPress> */ | |
| 30 | return $this->watchPushedCommands(); | |
| 31 | } | |
| 32 | ||
| 33 | /** @throws CommandException */ | |
| 34 | public function pushCommand(ButtonPress $command): void | |
| 35 | { | |
| 36 | $this->deliverCommand($command); | |
| 37 | } | |
| 38 | ||
| 39 | /** @throws CommandException */ | |
| 40 | public function pushPress(?EventContext $context = null): void | |
| 41 | { | |
| 42 | $this->pushCommand(new ButtonPress($context ?? EventContext::unknown())); | |
| 43 | } | |
| 44 | } |