Lines 0.00% 0 / 3
Functions and Methods 0.00% 0 / 3
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
HistoryRequest 0.00% 0 / 3 0.00% 0 / 3 12 0.00% 0 / 1
 __construct 0.00% 0 / 1 0.00% 0 / 1 2
 createUnreachableFailure 0.00% 0 / 1 0.00% 0 / 1 2
 createOverloadedFailure 0.00% 0 / 1 0.00% 0 / 1 2
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Ipc\Message;
6
7use Stewart\Contracts\Entity\EntityId;
8use Stewart\Contracts\Exception\HistoryError;
9use Stewart\Contracts\Exception\HistoryException;
10use Stewart\Contracts\History\HistoryDetail;
11use Stewart\Contracts\History\HistoryWindow;
12use Stewart\Runtime\Model\CorrelationId;
13use Stewart\Runtime\Model\ResourceScope;
14use Throwable;
15
16#[IpcMessage(tag: 'history_request')]
17final readonly class HistoryRequest implements WorkerMessage, RefusableHaCallRequest
18{
19    public function __construct(
20        public CorrelationId $correlationId,
21        public ResourceScope $scope,
22        public EntityId $entityId,
23        public HistoryWindow $window,
24        public HistoryDetail $detail,
25    ) {}
26
27    public function createUnreachableFailure(string $detail, ?Throwable $previous = null): HistoryException
28    {
29        return HistoryException::unreachable($this->entityId, $detail, $previous);
30    }
31
32    public function createOverloadedFailure(string $detail): HistoryException
33    {
34        return HistoryException::createForReason(HistoryError::Overloaded, entityId: $this->entityId->value, detail: $detail);
35    }
36}