|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Dazzle\Channel\Protocol; |
|
4
|
|
|
|
|
5
|
|
|
class Protocol implements ProtocolInterface |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* @var string |
|
9
|
|
|
*/ |
|
10
|
|
|
protected $type; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @var string |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $pid; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var string |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $destination; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $origin; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var string |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $message; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var string |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $exception; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var int |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $timestamp; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param string $type |
|
44
|
|
|
* @param string $pid |
|
45
|
|
|
* @param string $destination |
|
46
|
|
|
* @param string $origin |
|
47
|
|
|
* @param string $message |
|
48
|
|
|
* @param string $exception |
|
49
|
|
|
* @param int $timestamp |
|
50
|
|
|
*/ |
|
51
|
104 |
|
public function __construct($type = '', $pid = '', $destination = '', $origin = '', $message = '', $exception = '', $timestamp = 0) |
|
52
|
|
|
{ |
|
53
|
104 |
|
$this->type = $type; |
|
54
|
104 |
|
$this->pid = $pid; |
|
55
|
104 |
|
$this->destination = $destination; |
|
56
|
104 |
|
$this->origin = $origin; |
|
57
|
104 |
|
$this->message = $message; |
|
58
|
104 |
|
$this->exception = $exception; |
|
59
|
104 |
|
$this->timestamp = $timestamp; |
|
60
|
104 |
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* |
|
64
|
|
|
*/ |
|
65
|
104 |
|
public function __destruct() |
|
66
|
|
|
{ |
|
67
|
104 |
|
unset($this->type); |
|
68
|
104 |
|
unset($this->pid); |
|
69
|
104 |
|
unset($this->destination); |
|
70
|
104 |
|
unset($this->origin); |
|
71
|
104 |
|
unset($this->message); |
|
72
|
104 |
|
unset($this->exception); |
|
73
|
104 |
|
unset($this->timestamp); |
|
74
|
104 |
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @override |
|
78
|
|
|
* @inheritDoc |
|
79
|
|
|
*/ |
|
80
|
6 |
|
public function setType($type, $reassign = false) |
|
81
|
|
|
{ |
|
82
|
6 |
|
if ($this->type === '' || $reassign) |
|
83
|
|
|
{ |
|
84
|
5 |
|
$this->type = $type; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
6 |
|
return $this; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @override |
|
92
|
|
|
* @inheritDoc |
|
93
|
|
|
*/ |
|
94
|
9 |
|
public function setPid($pid, $reassign = false) |
|
95
|
|
|
{ |
|
96
|
9 |
|
if ($this->pid === '' || $reassign) |
|
97
|
|
|
{ |
|
98
|
8 |
|
$this->pid = $pid; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
9 |
|
return $this; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @override |
|
106
|
|
|
* @inheritDoc |
|
107
|
|
|
*/ |
|
108
|
6 |
|
public function setDestination($destination, $reassign = false) |
|
109
|
|
|
{ |
|
110
|
6 |
|
if ($this->destination === '' || $reassign) |
|
111
|
|
|
{ |
|
112
|
5 |
|
$this->destination = $destination; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
6 |
|
return $this; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @override |
|
120
|
|
|
* @inheritDoc |
|
121
|
|
|
*/ |
|
122
|
5 |
|
public function setOrigin($origin, $reassign = false) |
|
123
|
|
|
{ |
|
124
|
5 |
|
if ($this->origin === '' || $reassign) |
|
125
|
|
|
{ |
|
126
|
4 |
|
$this->origin = $origin; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
5 |
|
return $this; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @override |
|
134
|
|
|
* @inheritDoc |
|
135
|
|
|
*/ |
|
136
|
4 |
|
public function setMessage($message, $reassign = false) |
|
137
|
|
|
{ |
|
138
|
4 |
|
if ($this->message === '' || $reassign) |
|
139
|
|
|
{ |
|
140
|
3 |
|
$this->message = $message; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
4 |
|
return $this; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @override |
|
148
|
|
|
* @inheritDoc |
|
149
|
|
|
*/ |
|
150
|
4 |
|
public function setException($exception, $reassign = false) |
|
151
|
|
|
{ |
|
152
|
4 |
|
if ($this->exception === '' || $reassign) |
|
153
|
|
|
{ |
|
154
|
3 |
|
$this->exception = $exception; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
4 |
|
return $this; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* @override |
|
162
|
|
|
* @inheritDoc |
|
163
|
|
|
*/ |
|
164
|
26 |
|
public function setTimestamp($timestamp, $reassign = false) |
|
165
|
|
|
{ |
|
166
|
26 |
|
if ($this->timestamp == 0 || $reassign) |
|
167
|
|
|
{ |
|
168
|
25 |
|
$this->timestamp = $timestamp; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
26 |
|
return $this; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* @override |
|
176
|
|
|
* @inheritDoc |
|
177
|
|
|
*/ |
|
178
|
9 |
|
public function getType() |
|
179
|
|
|
{ |
|
180
|
9 |
|
return $this->type; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* @override |
|
185
|
|
|
* @inheritDoc |
|
186
|
|
|
*/ |
|
187
|
18 |
|
public function getPid() |
|
188
|
|
|
{ |
|
189
|
18 |
|
return $this->pid; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* @override |
|
194
|
|
|
* @inheritDoc |
|
195
|
|
|
*/ |
|
196
|
13 |
|
public function getDestination() |
|
197
|
|
|
{ |
|
198
|
13 |
|
return $this->destination; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* @override |
|
203
|
|
|
* @inheritDoc |
|
204
|
|
|
*/ |
|
205
|
14 |
|
public function getOrigin() |
|
206
|
|
|
{ |
|
207
|
14 |
|
return $this->origin; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* @override |
|
212
|
|
|
* @inheritDoc |
|
213
|
|
|
*/ |
|
214
|
19 |
|
public function getMessage() |
|
215
|
|
|
{ |
|
216
|
19 |
|
return $this->message; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* @override |
|
221
|
|
|
* @inheritDoc |
|
222
|
|
|
*/ |
|
223
|
12 |
|
public function getException() |
|
224
|
|
|
{ |
|
225
|
12 |
|
return $this->exception; |
|
226
|
|
|
} |
|
227
|
|
|
|
|
228
|
|
|
/** |
|
229
|
|
|
* @override |
|
230
|
|
|
* @inheritDoc |
|
231
|
|
|
*/ |
|
232
|
12 |
|
public function getTimestamp() |
|
233
|
|
|
{ |
|
234
|
12 |
|
return $this->timestamp; |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* @override |
|
239
|
|
|
* @inheritDoc |
|
240
|
|
|
*/ |
|
241
|
2 |
|
public function setAll($args = [], $reassign = false) |
|
242
|
|
|
{ |
|
243
|
2 |
|
$this->type = isset($args[0]) && ($this->type === '' || $reassign) ? $args[0] : $this->type; |
|
244
|
2 |
|
$this->pid = isset($args[1]) && ($this->pid === '' || $reassign) ? $args[1] : $this->pid; |
|
245
|
2 |
|
$this->destination = isset($args[2]) && ($this->destination === '' || $reassign) ? $args[2] : $this->destination; |
|
246
|
2 |
|
$this->origin = isset($args[3]) && ($this->origin === '' || $reassign) ? $args[3] : $this->origin; |
|
247
|
2 |
|
$this->message = isset($args[4]) && ($this->message === '' || $reassign) ? $args[4] : $this->message; |
|
248
|
2 |
|
$this->exception = isset($args[5]) && ($this->exception === '' || $reassign) ? $args[5] : $this->exception; |
|
249
|
2 |
|
$this->timestamp = isset($args[6]) && ($this->timestamp == 0 || $reassign) ? $args[6] : $this->timestamp; |
|
250
|
|
|
|
|
251
|
2 |
|
return $this; |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
/** |
|
255
|
|
|
* @override |
|
256
|
|
|
* @inheritDoc |
|
257
|
|
|
*/ |
|
258
|
3 |
|
public function getAll() |
|
259
|
|
|
{ |
|
260
|
|
|
return [ |
|
261
|
3 |
|
$this->type, |
|
262
|
3 |
|
$this->pid, |
|
263
|
3 |
|
$this->destination, |
|
264
|
3 |
|
$this->origin, |
|
265
|
3 |
|
$this->message, |
|
266
|
3 |
|
$this->exception, |
|
267
|
3 |
|
$this->timestamp |
|
268
|
|
|
]; |
|
269
|
|
|
} |
|
270
|
|
|
} |
|
271
|
|
|
|