Lines
100.00%
10 / 10
Methods
100.00%
7 / 7
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 3 | ||
| getId | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| getCreated | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| getExecuteAt | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| getType | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| getPayload | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| getRetries | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| 9 | final readonly class Message implements MessageInterface | |
| 10 | { | |
| 11 | private string $messageId; | |
| 12 | ||
| 13 | private float $created; | |
| 14 | ||
| 15 | /** | |
| 16 | * Native implementation of message. | |
| 17 | * | |
| 18 | * @param array<mixed>|null $payload | |
| 19 | * @param string|null $messageId null (the default) and '' both generate a UUID 4; any other string, including "0", is kept | |
| 20 | * @param float|null $created timestamp (microtime(true)) | |
| 21 | * @param float|null $executeAt timestamp (microtime(true)) | |
| 22 | */ | |
| 23 | public function __construct( | |
| 24 | private string $type, | |
| 25 | private ?array $payload = null, | |
| 26 | ?string $messageId = null, | |
| 27 | ?float $created = null, | |
| 28 | private ?float $executeAt = null, | |
| 29 | private int $retries = 0, | |
| 30 | ) { | |
| 31 | $this->messageId = ($messageId === null || $messageId === '') | |
| 32 | ? Uuid::uuid4()->toString() | |
| 33 | : $messageId; | |
| 34 | ||
| 35 | $this->created = $created ?? microtime(true); | |
| 36 | } | |
| 37 | ||
| 38 | #[\Override] | |
| 39 | public function getId(): string | |
| 40 | { | |
| 41 | return $this->messageId; | |
| 42 | } | |
| 43 | ||
| 44 | #[\Override] | |
| 45 | public function getCreated(): float | |
| 46 | { | |
| 47 | return $this->created; | |
| 48 | } | |
| 49 | ||
| 50 | #[\Override] | |
| 51 | public function getExecuteAt(): ?float | |
| 52 | { | |
| 53 | return $this->executeAt; | |
| 54 | } | |
| 55 | ||
| 56 | #[\Override] | |
| 57 | public function getType(): string | |
| 58 | { | |
| 59 | return $this->type; | |
| 60 | } | |
| 61 | ||
| 62 | #[\Override] | |
| 63 | public function getPayload(): ?array | |
| 64 | { | |
| 65 | return $this->payload; | |
| 66 | } | |
| 67 | ||
| 68 | #[\Override] | |
| 69 | public function getRetries(): int | |
| 70 | { | |
| 71 | return $this->retries; | |
| 72 | } | |
| 73 | } |