-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathMessage.php
More file actions
40 lines (33 loc) · 975 Bytes
/
Message.php
File metadata and controls
40 lines (33 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
declare(strict_types=1);
namespace Yiisoft\Queue\Message;
final class Message implements MessageInterface
{
/**
* @param string $handlerName A name of a handler which should handle this message.
* @param mixed $data Message data, encodable by a queue adapter
* @param array $metadata Message metadata, encodable by a queue adapter
*/
public function __construct(
private readonly string $handlerName,
private readonly mixed $data,
private array $metadata = [],
) {
}
public static function fromData(string $handlerName, mixed $data, array $metadata = []): MessageInterface
{
return new self($handlerName, $data, $metadata);
}
public function getHandlerName(): string
{
return $this->handlerName;
}
public function getData(): mixed
{
return $this->data;
}
public function getMetadata(): array
{
return $this->metadata;
}
}