-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
EventWasReceived.php
42 lines (35 loc) · 1.03 KB
/
EventWasReceived.php
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
41
42
<?php
declare(strict_types=1);
namespace Modules\Events\Domain\Events;
use App\Application\Broadcasting\Channel\EventsChannel;
use App\Application\Broadcasting\ShouldBroadcastInterface;
use App\Application\Domain\ValueObjects\Uuid;
final class EventWasReceived implements ShouldBroadcastInterface
{
public function __construct(
public readonly Uuid $uuid,
public readonly string $type,
public readonly array $payload,
public readonly float $timestamp,
public readonly ?int $projectId = null,
) {
}
public function jsonSerialize(): array
{
return [
'project_id' => $this->projectId,
'uuid' => (string)$this->uuid,
'type' => $this->type,
'payload' => $this->payload,
'timestamp' => $this->timestamp,
];
}
public function getEventName(): string
{
return 'event.received';
}
public function getBroadcastTopics(): iterable|string|\Stringable
{
return new EventsChannel();
}
}