Lines
n/a
0 / 0
Functions and Methods
n/a
0 / 0
Classes and Traits
n/a
0 / 0
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Contracts; | |
| 6 | ||
| 7 | use Stewart\Contracts\Connection\ConnectionEvent; | |
| 8 | use Stewart\Contracts\Entity\Entity; | |
| 9 | use Stewart\Contracts\Entity\EntityId; | |
| 10 | use Stewart\Contracts\Event\HaEvent; | |
| 11 | use Stewart\Contracts\Exception\EventFireException; | |
| 12 | use Stewart\Contracts\Exception\HistoryException; | |
| 13 | use Stewart\Contracts\Exception\IdentifierException; | |
| 14 | use Stewart\Contracts\Exception\SelectorException; | |
| 15 | use Stewart\Contracts\Exception\ServiceCallException; | |
| 16 | use Stewart\Contracts\Exception\StateException; | |
| 17 | use Stewart\Contracts\Exception\TopicException; | |
| 18 | use Stewart\Contracts\Exception\TriggerException; | |
| 19 | use Stewart\Contracts\Exception\WaitException; | |
| 20 | use Stewart\Contracts\History\EntityStateHistory; | |
| 21 | use Stewart\Contracts\History\HistoryQuery; | |
| 22 | use Stewart\Contracts\Registry\EntityFilter; | |
| 23 | use Stewart\Contracts\Registry\Registry; | |
| 24 | use Stewart\Contracts\Selector\Collection\SelectorCollection; | |
| 25 | use Stewart\Contracts\Selector\Selector; | |
| 26 | use Stewart\Contracts\Service\ServiceResponse; | |
| 27 | use Stewart\Contracts\Service\ServiceTargetSource; | |
| 28 | use Stewart\Contracts\State\Collection\EntityStateCollection; | |
| 29 | use Stewart\Contracts\State\EntityState; | |
| 30 | use Stewart\Contracts\State\EventContext; | |
| 31 | use Stewart\Contracts\State\StateChange; | |
| 32 | use Stewart\Contracts\Time\Duration; | |
| 33 | use Stewart\Contracts\Topic\TopicEvent; | |
| 34 | use Stewart\Contracts\Trigger\Collection\HaTriggerCollection; | |
| 35 | use Stewart\Contracts\Trigger\HaTrigger; | |
| 36 | use Stewart\Contracts\Trigger\TriggerEvent; | |
| 37 | ||
| 38 | interface HaContext | |
| 39 | { | |
| 40 | /** @throws IdentifierException */ | |
| 41 | public function getState(EntityId|string $entityId): ?EntityState; | |
| 42 | ||
| 43 | /** @throws IdentifierException */ | |
| 44 | public function getEntity(EntityId|string $entityId): Entity; | |
| 45 | ||
| 46 | /** @throws StateException|IdentifierException */ | |
| 47 | public function requireState(EntityId|string $entityId): EntityState; | |
| 48 | ||
| 49 | /** @throws HistoryException|IdentifierException */ | |
| 50 | public function getHistory(EntityId|string $entityId, HistoryQuery $query): EntityStateHistory; | |
| 51 | ||
| 52 | public function listStates(string|EntityId|Selector|SelectorCollection|EntityFilter|null $selector = null): EntityStateCollection; | |
| 53 | ||
| 54 | public function watchStateChanges(string|EntityId|Selector|SelectorCollection|EntityFilter $selector): StateChangeStream; | |
| 55 | ||
| 56 | // Returns at once when the entity is already in $state, and null once the timeout passes. | |
| 57 | /** @throws WaitException|IdentifierException */ | |
| 58 | public function waitForState(EntityId|string $entityId, string $state, ?Duration $timeout = null): ?EntityState; | |
| 59 | ||
| 60 | public function getRegistry(): Registry; | |
| 61 | ||
| 62 | /** | |
| 63 | * @return EventStream<HaEvent> | |
| 64 | * @throws StateException|SelectorException | |
| 65 | */ | |
| 66 | public function watchEvents(string|Selector|SelectorCollection $eventType): EventStream; | |
| 67 | ||
| 68 | /** | |
| 69 | * @param HaTrigger|HaTriggerCollection|array<array-key, mixed> $trigger | |
| 70 | * @param array<array-key, mixed> $variables | |
| 71 | * @return EventStream<TriggerEvent> | |
| 72 | * @throws TriggerException | |
| 73 | */ | |
| 74 | public function watchTrigger(HaTrigger|HaTriggerCollection|array $trigger, array $variables = []): EventStream; | |
| 75 | ||
| 76 | /** | |
| 77 | * @param array<string, mixed> $data | |
| 78 | * @throws ServiceCallException | |
| 79 | */ | |
| 80 | public function callService(string $domain, string $service, array $data = [], ?ServiceTargetSource $target = null): EventContext; | |
| 81 | ||
| 82 | /** | |
| 83 | * @param array<string, mixed> $data | |
| 84 | * @throws ServiceCallException | |
| 85 | */ | |
| 86 | public function callServiceForResponse(string $domain, string $service, array $data = [], ?ServiceTargetSource $target = null): ServiceResponse; | |
| 87 | ||
| 88 | /** | |
| 89 | * @param array<string, mixed> $data | |
| 90 | * @throws EventFireException | |
| 91 | */ | |
| 92 | public function fireEvent(string $eventType, array $data = []): EventContext; | |
| 93 | ||
| 94 | public function wasCausedByStewart(StateChange|EntityState|HaEvent $subject): bool; | |
| 95 | ||
| 96 | /** | |
| 97 | * @param array<array-key, mixed>|scalar|null $payload | |
| 98 | * @throws TopicException | |
| 99 | */ | |
| 100 | public function publish(string $topic, bool|int|float|string|array|null $payload = null): void; | |
| 101 | ||
| 102 | /** @return EventStream<TopicEvent> */ | |
| 103 | public function watchTopic(string|Selector|SelectorCollection $topic): EventStream; | |
| 104 | ||
| 105 | /** @return EventStream<ConnectionEvent> */ | |
| 106 | public function watchConnection(): EventStream; | |
| 107 | ||
| 108 | public function isConnected(): bool; | |
| 109 | } |