Lines 75.75% 25 / 33
Methods 61.90% 13 / 21
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
 watchCommands 0.00% 0 / 1 0.00% 0 / 1 2
 pushCommand 0.00% 0 / 1 0.00% 0 / 1 2
 [Stewart\Testing\Exposure\RecordingExposedEntity] __construct 100.00% 2 / 2 100.00% 1 / 1 1
 [Stewart\Testing\Exposure\RecordingExposedEntity] applySnapshot 100.00% 4 / 4 100.00% 1 / 1 1
 [Stewart\Testing\Exposure\RecordingExposedEntity] getEntityId 100.00% 1 / 1 100.00% 1 / 1 1
 [Stewart\Testing\Exposure\RecordingExposedEntity] getAttributes 0.00% 0 / 1 0.00% 0 / 1 2
 [Stewart\Testing\Exposure\RecordingExposedEntity] isAvailable 100.00% 1 / 1 100.00% 1 / 1 1
 [Stewart\Testing\Exposure\RecordingExposedEntity] setAttributes 0.00% 0 / 1 0.00% 0 / 1 2
 [Stewart\Testing\Exposure\RecordingExposedEntity] markAvailable 0.00% 0 / 1 0.00% 0 / 1 2
 [Stewart\Testing\Exposure\RecordingExposedEntity] markUnavailable 100.00% 1 / 1 100.00% 1 / 1 1
 [Stewart\Testing\Exposure\RecordingExposedEntity] recordChange 100.00% 5 / 5 100.00% 1 / 1 1
 [Stewart\Testing\Exposure\RecordingExposedEntity] deliverCommand 100.00% 2 / 2 100.00% 1 / 1 1
 [Stewart\Testing\Exposure\RecordingExposedEntity] findStateValue 100.00% 1 / 1 100.00% 1 / 1 1
 [Stewart\Testing\Exposure\RecordingExposure] getKey 100.00% 1 / 1 100.00% 1 / 1 1
 [Stewart\Testing\Exposure\RecordingExposure] cancelCommandSubscriptions 0.00% 0 / 1 0.00% 0 / 1 2
 [Stewart\Testing\Exposure\RecordingExposure] remove 100.00% 2 / 2 100.00% 1 / 1 1
 [Stewart\Testing\Exposure\RecordingExposure] recordConfig 100.00% 2 / 2 100.00% 1 / 1 1
 [Stewart\Testing\Exposure\RecordingExposure] watchPushedCommands 100.00% 1 / 1 100.00% 1 / 1 1
 [Stewart\Testing\Exposure\RecordingExposure] assertNotRemoved 100.00% 2 / 2 100.00% 1 / 1 2
14final class RecordingExposedButton extends RecordingExposedEntity implements ExposedButton
15{
16    public function getConfig(): ButtonConfig
17    {
18        return $this->config;
19    }
20
21    public function updateConfig(ButtonConfig $config): void
22    {
23        $this->recordConfig($config);
24    }
25
26    public function watchCommands(): EventStream
27    {
28        /** @var EventStream<ButtonPress> */
29        return $this->watchPushedCommands();
30    }
31
32    /** @throws CommandException */
33    public function pushCommand(ButtonPress $command): void
34    {
35        $this->deliverCommand($command);
36    }
37}

Inherited from Stewart\Testing\Exposure\RecordingExposedEntity

39    public function __construct(ExposedEntityKey $key, ExposedEntityConfig $config, ManualTimers $timers)
40    {
41        parent::__construct($key, $config, $timers);
42        $this->changes = ExposedStateChangeCollection::empty();
43    }
45    public function applySnapshot(ExposedEntitySnapshot $snapshot): void
46    {
47        $this->entityId = $snapshot->entityId;
48        $this->state = $snapshot->state;
49        $this->attributes = $snapshot->attributes;
50        $this->available = $snapshot->available;
51    }
53    public function getEntityId(): ?EntityId
54    {
55        return $this->entityId;
56    }
58    public function getAttributes(): array
59    {
60        return $this->attributes;
61    }
63    public function isAvailable(): bool
64    {
65        return $this->available;
66    }
68    public function setAttributes(array $attributes): void
69    {
70        $this->recordChange(new ExposedStateChange(attributes: $attributes));
71    }
73    public function markAvailable(): void
74    {
75        $this->recordChange(new ExposedStateChange(available: true));
76    }
78    public function markUnavailable(): void
79    {
80        $this->recordChange(new ExposedStateChange(available: false));
81    }
84    protected function recordChange(ExposedStateChange $change): void
85    {
86        $this->assertNotRemoved();
87        $this->changes = $this->changes->withChange($change);
88        $this->state = $change->state ?? $this->state;
89        $this->attributes = $change->attributes ?? $this->attributes;
90        $this->available = $change->available ?? $this->available;
91    }
93    protected function deliverCommand(ExposedCommand $command): void
94    {
95        parent::deliverCommand($command);
96        $this->state = $command->getRequestedState() ?? $this->state;
97    }
99    protected function findStateValue(): int|float|string|bool|null
100    {
101        return $this->state?->value;
102    }

Inherited from Stewart\Testing\Exposure\RecordingExposure

34    public function getKey(): ExposedEntityKey
35    {
36        return $this->key;
37    }
39    public function cancelCommandSubscriptions(): void
40    {
41        $this->commands->cancelAttachments();
42    }
44    public function remove(): void
45    {
46        $this->assertNotRemoved();
47        $this->removed = true;
48    }
54    protected function recordConfig(ExposureConfig $config): void
55    {
56        $this->assertNotRemoved();
57        $this->config = $config;
58    }
61    protected function watchPushedCommands(): EventStream
62    {
63        return new OperatorStream($this->commands, $this->timers);
64    }
73    protected function assertNotRemoved(): void
74    {
75        if ($this->removed) {
76            throw ExposureException::removed($this->key);
77        }
78    }