1 | <?php |
||
17 | final class Event |
||
18 | { |
||
19 | private $event; |
||
20 | private $id; |
||
21 | private $timestamp; |
||
22 | private $eventDate; |
||
23 | private $tags; |
||
24 | private $url; |
||
25 | private $severity; |
||
26 | private $envelope; |
||
27 | private $deliveryStatus; |
||
28 | private $campaigns; |
||
29 | private $ip; |
||
30 | private $clientInfo; |
||
31 | private $reason; |
||
32 | private $userVariables; |
||
33 | private $flags; |
||
34 | private $routes; |
||
35 | private $message; |
||
36 | private $recipient; |
||
37 | private $geolocation; |
||
38 | private $storage; |
||
39 | private $method; |
||
40 | private $logLevel; |
||
41 | |||
42 | 2 | private function __construct() |
|
43 | { |
||
44 | 2 | } |
|
45 | |||
46 | 2 | public static function create(array $data): self |
|
47 | { |
||
48 | 2 | $model = new self(); |
|
49 | 2 | $model->event = $data['event']; |
|
50 | 2 | $model->id = $data['id']; |
|
51 | 2 | $model->timestamp = (int) $data['timestamp']; |
|
52 | 2 | $model->eventDate = (new \DateTimeImmutable())->setTimestamp((int) $data['timestamp']); |
|
53 | 2 | $model->tags = $data['tags'] ?? []; |
|
54 | 2 | $model->envelope = $data['envelope'] ?? []; |
|
55 | 2 | $model->campaigns = $data['campaigns'] ?? []; |
|
56 | 2 | $model->userVariables = $data['user-variables'] ?? []; |
|
57 | 2 | $model->flags = $data['flags'] ?? []; |
|
58 | 2 | $model->routes = $data['routes'] ?? []; |
|
59 | 2 | $model->message = $data['message'] ?? []; |
|
60 | 2 | $model->recipient = $data['recipient'] ?? ''; |
|
61 | 2 | $model->method = $data['method'] ?? ''; |
|
62 | 2 | $model->deliveryStatus = $data['delivery-status'] ?? []; |
|
63 | 2 | $model->severity = $data['severity'] ?? ''; |
|
64 | 2 | $model->reason = $data['reason'] ?? ''; |
|
65 | 2 | $model->geolocation = $data['geolocation'] ?? []; |
|
66 | 2 | $model->ip = $data['ip'] ?? ''; |
|
67 | 2 | $model->clientInfo = $data['client-info'] ?? []; |
|
68 | 2 | $model->url = $data['url'] ?? ''; |
|
69 | 2 | $model->storage = $data['storage'] ?? []; |
|
70 | 2 | $model->logLevel = $data['log-level'] ?? ''; |
|
71 | |||
72 | 2 | return $model; |
|
73 | } |
||
74 | |||
75 | 1 | public function getEvent(): string |
|
79 | |||
80 | 1 | public function getId(): string |
|
81 | { |
||
82 | 1 | return $this->id; |
|
83 | } |
||
84 | |||
85 | public function getTimestamp(): int |
||
86 | { |
||
87 | return $this->timestamp; |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * A \DateTimeImmutable representation of $timestamp. |
||
92 | */ |
||
93 | public function getEventDate(): \DateTimeImmutable |
||
94 | { |
||
95 | return $this->eventDate; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * @return string[] |
||
100 | */ |
||
101 | public function getTags(): array |
||
105 | |||
106 | public function getUrl(): string |
||
110 | |||
111 | public function getSeverity(): string |
||
115 | |||
116 | public function getEnvelope(): array |
||
120 | |||
121 | public function getDeliveryStatus(): array |
||
122 | { |
||
123 | return $this->deliveryStatus; |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * @return string[] |
||
128 | */ |
||
129 | public function getCampaigns(): array |
||
133 | |||
134 | public function getIp(): string |
||
138 | |||
139 | public function getClientInfo(): array |
||
143 | |||
144 | public function getReason(): string |
||
148 | |||
149 | public function getUserVariables(): array |
||
150 | { |
||
151 | return $this->userVariables; |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * key=>bool. |
||
156 | */ |
||
157 | public function getFlags(): array |
||
158 | { |
||
159 | return $this->flags; |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * multi dimensions. |
||
164 | */ |
||
165 | public function getRoutes(): array |
||
166 | { |
||
167 | return $this->routes; |
||
168 | } |
||
169 | |||
170 | /** |
||
171 | * multi dimensions. |
||
172 | */ |
||
173 | public function getMessage(): array |
||
177 | |||
178 | public function getRecipient(): string |
||
182 | |||
183 | public function getGeolocation(): array |
||
187 | |||
188 | public function getStorage(): array |
||
192 | |||
193 | public function getMethod(): string |
||
194 | { |
||
195 | return $this->method; |
||
196 | } |
||
197 | |||
198 | 1 | public function getLogLevel(): string |
|
199 | { |
||
200 | 1 | return $this->logLevel; |
|
201 | } |
||
202 | } |
||
203 |