1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* event-async (https://github.com/phpgears/event-async). |
5
|
|
|
* Async decorator for Event bus. |
6
|
|
|
* |
7
|
|
|
* @license MIT |
8
|
|
|
* @link https://github.com/phpgears/event-async |
9
|
|
|
* @author Julián Gutiérrez <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Gears\Event\Async; |
15
|
|
|
|
16
|
|
|
use Gears\Event\Async\Exception\ReceivedEventException; |
17
|
|
|
use Gears\Event\Event; |
18
|
|
|
|
19
|
|
|
final class ReceivedEvent implements Event |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var Event |
23
|
|
|
*/ |
24
|
|
|
private $originalEvent; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* ReceivedEvent constructor. |
28
|
|
|
* |
29
|
|
|
* @param Event $originalEvent |
30
|
|
|
*/ |
31
|
|
|
public function __construct(Event $originalEvent) |
32
|
|
|
{ |
33
|
|
|
$this->originalEvent = $originalEvent; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Get original event. |
38
|
|
|
* |
39
|
|
|
* @return Event |
40
|
|
|
*/ |
41
|
|
|
public function getOriginalEvent(): Event |
42
|
|
|
{ |
43
|
|
|
return $this->originalEvent; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
* |
49
|
|
|
* @throws ReceivedEventException |
50
|
|
|
*/ |
51
|
|
|
public function getEventType(): string |
52
|
|
|
{ |
53
|
|
|
throw new ReceivedEventException(\sprintf('Method %s should not be called ', __METHOD__)); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritdoc} |
58
|
|
|
* |
59
|
|
|
* @throws ReceivedEventException |
60
|
|
|
*/ |
61
|
|
|
public function has(string $parameter): bool |
62
|
|
|
{ |
63
|
|
|
throw new ReceivedEventException(\sprintf('Method %s should not be called ', __METHOD__)); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* {@inheritdoc} |
68
|
|
|
* |
69
|
|
|
* @throws ReceivedEventException |
70
|
|
|
* |
71
|
|
|
* @return mixed |
72
|
|
|
*/ |
73
|
|
|
public function get(string $parameter) |
74
|
|
|
{ |
75
|
|
|
throw new ReceivedEventException(\sprintf('Method %s should not be called ', __METHOD__)); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* {@inheritdoc} |
80
|
|
|
* |
81
|
|
|
* @throws ReceivedEventException |
82
|
|
|
* |
83
|
|
|
* @return array<string, mixed> |
84
|
|
|
*/ |
85
|
|
|
public function getPayload(): array |
86
|
|
|
{ |
87
|
|
|
throw new ReceivedEventException(\sprintf('Method %s should not be called ', __METHOD__)); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* {@inheritdoc} |
92
|
|
|
* |
93
|
|
|
* @throws ReceivedEventException |
94
|
|
|
* |
95
|
|
|
* @return array<string, mixed> |
96
|
|
|
*/ |
97
|
|
|
public function getMetadata(): array |
98
|
|
|
{ |
99
|
|
|
throw new ReceivedEventException(\sprintf('Method %s should not be called ', __METHOD__)); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* {@inheritdoc} |
104
|
|
|
* |
105
|
|
|
* @throws ReceivedEventException |
106
|
|
|
* |
107
|
|
|
* @return array<string, mixed> |
108
|
|
|
*/ |
109
|
|
|
public function withAddedMetadata(array $metadata) |
110
|
|
|
{ |
111
|
|
|
throw new ReceivedEventException(\sprintf('Method %s should not be called ', __METHOD__)); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* {@inheritdoc} |
116
|
|
|
* |
117
|
|
|
* @throws ReceivedEventException |
118
|
|
|
*/ |
119
|
|
|
public function getCreatedAt(): \DateTimeImmutable |
120
|
|
|
{ |
121
|
|
|
throw new ReceivedEventException(\sprintf('Method %s should not be called ', __METHOD__)); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* {@inheritdoc} |
126
|
|
|
* |
127
|
|
|
* @throws ReceivedEventException |
128
|
|
|
*/ |
129
|
|
|
public static function reconstitute(array $payload, \DateTimeImmutable $createdAt, array $attributes = []): void |
130
|
|
|
{ |
131
|
|
|
throw new ReceivedEventException(\sprintf('Method %s should not be called ', __METHOD__)); |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|