Completed
Push — master ( 90028d...27d579 )
by David
03:16
created

Event::getCampaigns()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (C) 2013 Mailgun
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license. See the LICENSE file for details.
10
 */
11
12
namespace Mailgun\Model\Event;
13
14
/**
15
 * @author Tobias Nyholm <[email protected]>
16
 */
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
76
    {
77 1
        return $this->event;
78
    }
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
102
    {
103
        return $this->tags;
104
    }
105
106
    public function getUrl(): string
107
    {
108
        return $this->url;
109
    }
110
111
    public function getSeverity(): string
112
    {
113
        return $this->severity;
114
    }
115
116
    public function getEnvelope(): array
117
    {
118
        return $this->envelope;
119
    }
120
121
    public function getDeliveryStatus(): array
122
    {
123
        return $this->deliveryStatus;
124
    }
125
126
    /**
127
     * @return string[]
128
     */
129
    public function getCampaigns(): array
130
    {
131
        return $this->campaigns;
132
    }
133
134
    public function getIp(): string
135
    {
136
        return $this->ip;
137
    }
138
139
    public function getClientInfo(): array
140
    {
141
        return $this->clientInfo;
142
    }
143
144
    public function getReason(): string
145
    {
146
        return $this->reason;
147
    }
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
174
    {
175
        return $this->message;
176
    }
177
178
    public function getRecipient(): string
179
    {
180
        return $this->recipient;
181
    }
182
183
    public function getGeolocation(): array
184
    {
185
        return $this->geolocation;
186
    }
187
188
    public function getStorage(): array
189
    {
190
        return $this->storage;
191
    }
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