Lines
33.33%
2 / 6
Functions and Methods
20.00%
1 / 5
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| RecordingExposedBinarySensor | 33.33% | 2 / 6 | 20.00% | 1 / 5 | 16.67 | 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 | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 2 | |||||
| setOn | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| setOff | 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\Exposure\BinarySensorConfig; | |
| 8 | use Stewart\Contracts\Exposure\ExposedBinarySensor; | |
| 9 | use Stewart\Contracts\Exposure\ExposedState; | |
| 10 | use Stewart\Contracts\Exposure\ExposedStateChange; | |
| 11 | ||
| 12 | /** @extends RecordingExposedEntity<BinarySensorConfig> */ | |
| 13 | final class RecordingExposedBinarySensor extends RecordingExposedEntity implements ExposedBinarySensor | |
| 14 | { | |
| 15 | public function getConfig(): BinarySensorConfig | |
| 16 | { | |
| 17 | return $this->config; | |
| 18 | } | |
| 19 | ||
| 20 | public function updateConfig(BinarySensorConfig $config): void | |
| 21 | { | |
| 22 | $this->recordConfig($config); | |
| 23 | } | |
| 24 | ||
| 25 | public function getValue(): ?bool | |
| 26 | { | |
| 27 | $value = $this->findStateValue(); | |
| 28 | ||
| 29 | return \is_bool($value) ? $value : null; | |
| 30 | } | |
| 31 | ||
| 32 | public function setOn(?array $attributes = null): void | |
| 33 | { | |
| 34 | $this->recordChange(new ExposedStateChange(new ExposedState(true), $attributes)); | |
| 35 | } | |
| 36 | ||
| 37 | public function setOff(?array $attributes = null): void | |
| 38 | { | |
| 39 | $this->recordChange(new ExposedStateChange(new ExposedState(false), $attributes)); | |
| 40 | } | |
| 41 | } |