Lines
14.28%
1 / 7
Functions and Methods
16.66%
1 / 6
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| RecordingExposedTime | 14.28% | 1 / 7 | 16.66% | 1 / 6 | 48.30 | 0.00% | 0 / 1 | |||
| getConfig | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| updateConfig | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| getValue | 0.00% | 0 / 2 | 0.00% | 0 / 1 | 6 | |||||
| setValue | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | |||||
| watchCommands | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| pushCommand | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| 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\CalendarStateFormat; | |
| 10 | use Stewart\Contracts\Exposure\Command\TimeCommand; | |
| 11 | use Stewart\Contracts\Exposure\ExposedState; | |
| 12 | use Stewart\Contracts\Exposure\ExposedStateChange; | |
| 13 | use Stewart\Contracts\Exposure\ExposedTime; | |
| 14 | use Stewart\Contracts\Exposure\TimeConfig; | |
| 15 | use Stewart\Contracts\Schedule\TimeOfDay; | |
| 16 | ||
| 17 | /** @extends RecordingExposedEntity<TimeConfig> */ | |
| 18 | final class RecordingExposedTime extends RecordingExposedEntity implements ExposedTime | |
| 19 | { | |
| 20 | public function getConfig(): TimeConfig | |
| 21 | { | |
| 22 | return $this->config; | |
| 23 | } | |
| 24 | ||
| 25 | public function updateConfig(TimeConfig $config): void | |
| 26 | { | |
| 27 | $this->recordConfig($config); | |
| 28 | } | |
| 29 | ||
| 30 | public function getValue(): ?TimeOfDay | |
| 31 | { | |
| 32 | $value = $this->findStateValue(); | |
| 33 | ||
| 34 | return \is_string($value) ? CalendarStateFormat::parseTime($value) : null; | |
| 35 | } | |
| 36 | ||
| 37 | public function setValue(?TimeOfDay $value, ?array $attributes = null): void | |
| 38 | { | |
| 39 | $this->recordChange(new ExposedStateChange(new ExposedState($value === null ? null : CalendarStateFormat::formatTime($value)), $attributes)); | |
| 40 | } | |
| 41 | ||
| 42 | public function watchCommands(): EventStream | |
| 43 | { | |
| 44 | /** @var EventStream<TimeCommand> */ | |
| 45 | return $this->watchPushedCommands(); | |
| 46 | } | |
| 47 | ||
| 48 | /** @throws CommandException */ | |
| 49 | public function pushCommand(TimeCommand $command): void | |
| 50 | { | |
| 51 | $this->deliverCommand($command); | |
| 52 | } | |
| 53 | } |