1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the AppleApnPush package |
7
|
|
|
* |
8
|
|
|
* (c) Vitaliy Zhuk <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Apple\ApnPush\Model; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Default APS data |
18
|
|
|
*/ |
19
|
|
|
class Aps |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var Alert |
23
|
|
|
*/ |
24
|
|
|
private $alert; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var int |
28
|
|
|
*/ |
29
|
|
|
private $badge = 0; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
private $sound = ''; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var bool |
38
|
|
|
*/ |
39
|
|
|
private $contentAvailable = false; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var bool |
43
|
|
|
*/ |
44
|
|
|
private $mutableContent = false; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
private $category = ''; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
private $threadId = ''; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Constructor. |
58
|
|
|
* |
59
|
|
|
* @param Alert $alert |
60
|
|
|
*/ |
61
|
|
|
public function __construct(Alert $alert) |
62
|
|
|
{ |
63
|
|
|
$this->alert = $alert; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Set alert |
68
|
|
|
* |
69
|
|
|
* @param Alert $alert |
70
|
|
|
* |
71
|
|
|
* @return Aps |
72
|
|
|
*/ |
73
|
|
|
public function withAlert(Alert $alert): Aps |
74
|
|
|
{ |
75
|
|
|
$cloned = clone $this; |
76
|
|
|
|
77
|
|
|
$cloned->alert = $alert; |
78
|
|
|
|
79
|
|
|
return $cloned; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Get alert data |
84
|
|
|
* |
85
|
|
|
* @return Alert |
86
|
|
|
*/ |
87
|
|
|
public function getAlert(): Alert |
88
|
|
|
{ |
89
|
|
|
return $this->alert; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Set category |
94
|
|
|
* |
95
|
|
|
* @param string $category |
96
|
|
|
* |
97
|
|
|
* @return Aps |
98
|
|
|
*/ |
99
|
|
|
public function withCategory(string $category): Aps |
100
|
|
|
{ |
101
|
|
|
$cloned = clone $this; |
102
|
|
|
|
103
|
|
|
$cloned->category = $category; |
104
|
|
|
|
105
|
|
|
return $cloned; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Get category |
110
|
|
|
* |
111
|
|
|
* @return string |
112
|
|
|
*/ |
113
|
|
|
public function getCategory(): string |
114
|
|
|
{ |
115
|
|
|
return $this->category; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Set sound |
120
|
|
|
* |
121
|
|
|
* @param string $sound |
122
|
|
|
* |
123
|
|
|
* @return Aps |
124
|
|
|
*/ |
125
|
|
|
public function withSound(string $sound): Aps |
126
|
|
|
{ |
127
|
|
|
$cloned = clone $this; |
128
|
|
|
|
129
|
|
|
$cloned->sound = $sound; |
130
|
|
|
|
131
|
|
|
return $cloned; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Get sound |
136
|
|
|
* |
137
|
|
|
* @return string |
138
|
|
|
*/ |
139
|
|
|
public function getSound(): string |
140
|
|
|
{ |
141
|
|
|
return $this->sound; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Set badge |
146
|
|
|
* |
147
|
|
|
* @param int $badge |
148
|
|
|
* |
149
|
|
|
* @return Aps |
150
|
|
|
*/ |
151
|
|
|
public function withBadge(int $badge): Aps |
152
|
|
|
{ |
153
|
|
|
$cloned = clone $this; |
154
|
|
|
|
155
|
|
|
$cloned->badge = (int) $badge; |
156
|
|
|
|
157
|
|
|
return $cloned; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Get badge |
162
|
|
|
* |
163
|
|
|
* @return int |
164
|
|
|
*/ |
165
|
|
|
public function getBadge(): int |
166
|
|
|
{ |
167
|
|
|
return $this->badge; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Set content available option |
172
|
|
|
* |
173
|
|
|
* @param bool $contentAvailable |
174
|
|
|
* |
175
|
|
|
* @return Aps |
176
|
|
|
*/ |
177
|
|
|
public function withContentAvailable(bool $contentAvailable): Aps |
178
|
|
|
{ |
179
|
|
|
$cloned = clone $this; |
180
|
|
|
|
181
|
|
|
$cloned->contentAvailable = $contentAvailable; |
182
|
|
|
|
183
|
|
|
return $cloned; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Get content available option |
188
|
|
|
* |
189
|
|
|
* @return bool |
190
|
|
|
*/ |
191
|
|
|
public function isContentAvailable(): bool |
192
|
|
|
{ |
193
|
|
|
return $this->contentAvailable; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* Set mutable content option |
198
|
|
|
* |
199
|
|
|
* @param bool $mutableContent |
200
|
|
|
* |
201
|
|
|
* @return Aps |
202
|
|
|
*/ |
203
|
|
|
public function withMutableContent(bool $mutableContent): Aps |
204
|
|
|
{ |
205
|
|
|
$cloned = clone $this; |
206
|
|
|
|
207
|
|
|
$cloned->mutableContent = $mutableContent; |
208
|
|
|
|
209
|
|
|
return $cloned; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Get mutable content option |
214
|
|
|
* |
215
|
|
|
* @return bool |
216
|
|
|
*/ |
217
|
|
|
public function isMutableContent(): bool |
218
|
|
|
{ |
219
|
|
|
return $this->mutableContent; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* Set thread id |
224
|
|
|
* |
225
|
|
|
* @param string $threadId |
226
|
|
|
* |
227
|
|
|
* @return Aps |
228
|
|
|
*/ |
229
|
|
|
public function withThreadId(string $threadId): Aps |
230
|
|
|
{ |
231
|
|
|
$cloned = clone $this; |
232
|
|
|
|
233
|
|
|
$cloned->threadId = $threadId; |
234
|
|
|
|
235
|
|
|
return $cloned; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* Get thread id |
240
|
|
|
* |
241
|
|
|
* @return string |
242
|
|
|
*/ |
243
|
|
|
public function getThreadId(): string |
244
|
|
|
{ |
245
|
|
|
return $this->threadId; |
246
|
|
|
} |
247
|
|
|
} |
248
|
|
|
|