Lines
100.00%
2 / 2
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| HaEvent | 100.00% | 2 / 2 | 100.00% | 2 / 2 | 2 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| getValue | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Contracts\Event; | |
| 6 | ||
| 7 | use Stewart\Contracts\State\EventContext; | |
| 8 | use Stewart\Contracts\Time\Instant; | |
| 9 | ||
| 10 | final readonly class HaEvent | |
| 11 | { | |
| 12 | public const string STATE_CHANGED = 'state_changed'; | |
| 13 | ||
| 14 | /** @param array<string, mixed> $data */ | |
| 15 | public function __construct( | |
| 16 | public string $type, | |
| 17 | public array $data = [], | |
| 18 | public EventOrigin $origin = EventOrigin::Local, | |
| 19 | public ?Instant $firedAt = null, | |
| 20 | public ?EventContext $context = null, | |
| 21 | ) {} | |
| 22 | ||
| 23 | public function getValue(string $key): mixed | |
| 24 | { | |
| 25 | return $this->data[$key] ?? null; | |
| 26 | } | |
| 27 | } |