Lines
78.26%
18 / 23
Methods
64.28%
9 / 14
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| getConfig | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| updateConfig | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| watchCalls | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| applySnapshot | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| recordCommandedState | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| [Stewart\Runtime\Worker\Exposure\WorkerExposure] __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Runtime\Worker\Exposure\WorkerExposure] getKey | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Runtime\Worker\Exposure\WorkerExposure] remove | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Runtime\Worker\Exposure\WorkerExposure] markReleased | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Runtime\Worker\Exposure\WorkerExposure] findConfig | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Runtime\Worker\Exposure\WorkerExposure] watchOwnCommands | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Runtime\Worker\Exposure\WorkerExposure] sendReconfiguration | 100.00% | 5 / 5 | 100.00% | 1 / 1 | 2 | ||
| [Stewart\Runtime\Worker\Exposure\WorkerExposure] sendUpdate | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Runtime\Worker\Exposure\WorkerExposure] assertNotReleased | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 2 | ||
| 15 | final class WorkerExposedAction extends WorkerExposure implements ExposedAction | |
| 16 | { | |
| 17 | public function getConfig(): ActionConfig | |
| 18 | { | |
| 19 | return $this->findConfig(); | |
| 20 | } | |
| 21 | ||
| 22 | public function updateConfig(ActionConfig $config): void | |
| 23 | { | |
| 24 | $this->sendReconfiguration($config); | |
| 25 | } | |
| 26 | ||
| 27 | public function watchCalls(): EventStream | |
| 28 | { | |
| 29 | /** @var EventStream<ActionCall> */ | |
| 30 | return $this->watchOwnCommands(); | |
| 31 | } | |
| 32 | ||
| 33 | // An action has no entity in Home Assistant, so there is no state to track. | |
| 34 | public function applySnapshot(ExposedEntitySnapshot $snapshot): void {} | |
| 35 | ||
| 36 | public function recordCommandedState(ExposedState $state): void {} | |
| 37 | } |
Inherited from Stewart\Runtime\Worker\Exposure\WorkerExposure
| 21 | public function __construct( | |
| 22 | private readonly ExposureChannel $channel, | |
| 23 | private readonly ResourceScope $scope, | |
| 24 | private readonly ExposedEntityKey $key, | |
| 25 | private ExposureConfig $config, | |
| 26 | ) {} |
| 28 | public function getKey(): ExposedEntityKey | |
| 29 | { | |
| 30 | return $this->key; | |
| 31 | } |
| 33 | public function remove(): void | |
| 34 | { | |
| 35 | $this->assertNotReleased(); | |
| 36 | $this->channel->requester->requestRemoval($this->scope, $this->key); | |
| 37 | $this->channel->handles->forgetHandle($this->scope, $this->key); | |
| 38 | $this->released = true; | |
| 39 | } |
| 41 | public function markReleased(): void | |
| 42 | { | |
| 43 | $this->released = true; | |
| 44 | } |
| 47 | protected function findConfig(): ExposureConfig | |
| 48 | { | |
| 49 | return $this->config; | |
| 50 | } |
| 53 | protected function watchOwnCommands(): EventStream | |
| 54 | { | |
| 55 | return $this->channel->commandStreams->watchCommands($this->scope, $this->key); | |
| 56 | } |
| 62 | protected function sendReconfiguration(ExposureConfig $config): void | |
| 63 | { | |
| 64 | $this->assertNotReleased(); | |
| 65 | $snapshot = $this->channel->requester->requestReconfiguration($this->scope, $this->key, $config); | |
| 66 | $this->config = $config; | |
| 67 | ||
| 68 | if ($snapshot !== null) { | |
| 69 | $this->applySnapshot($snapshot); | |
| 70 | } | |
| 71 | } |
| 74 | protected function sendUpdate(ExposedStateChange $change): void | |
| 75 | { | |
| 76 | $this->assertNotReleased(); | |
| 77 | $this->channel->requester->requestUpdate($this->scope, $this->key, $change); | |
| 78 | } |
| 81 | private function assertNotReleased(): void | |
| 82 | { | |
| 83 | if ($this->released) { | |
| 84 | throw ExposureException::removed($this->key); | |
| 85 | } | |
| 86 | } |