Lines
92.30%
12 / 13
Functions and Methods
75.00%
3 / 4
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| GetHistoryDuringPeriod | 92.30% | 12 / 13 | 75.00% | 3 / 4 | 4.01 | 0.00% | 0 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| type | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| describe | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| toMessage | 100.00% | 10 / 10 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Client\Connection\Command; | |
| 6 | ||
| 7 | use Stewart\Contracts\Entity\EntityId; | |
| 8 | use Stewart\Contracts\History\HistoryDetail; | |
| 9 | use Stewart\Contracts\History\HistoryWindow; | |
| 10 | ||
| 11 | final readonly class GetHistoryDuringPeriod implements HaCommand | |
| 12 | { | |
| 13 | public function __construct( | |
| 14 | public EntityId $entityId, | |
| 15 | public HistoryWindow $window, | |
| 16 | public HistoryDetail $detail = HistoryDetail::StateChanges, | |
| 17 | ) {} | |
| 18 | ||
| 19 | public function type(): string | |
| 20 | { | |
| 21 | return 'history/history_during_period'; | |
| 22 | } | |
| 23 | ||
| 24 | public function describe(): string | |
| 25 | { | |
| 26 | return \sprintf('%s %s', $this->type(), $this->entityId->value); | |
| 27 | } | |
| 28 | ||
| 29 | public function toMessage(): array | |
| 30 | { | |
| 31 | return [ | |
| 32 | 'type' => $this->type(), | |
| 33 | 'start_time' => $this->window->startsAt->toIso8601(), | |
| 34 | 'end_time' => $this->window->endsAt->toIso8601(), | |
| 35 | 'entity_ids' => [$this->entityId->value], | |
| 36 | 'include_start_time_state' => true, | |
| 37 | 'significant_changes_only' => !$this->detail->includesAttributeOnlyChanges(), | |
| 38 | 'minimal_response' => !$this->detail->includesAttributes(), | |
| 39 | 'no_attributes' => !$this->detail->includesAttributes(), | |
| 40 | ]; | |
| 41 | } | |
| 42 | } |