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
|
|
|
* Value object for alert object |
18
|
|
|
*/ |
19
|
|
|
class Alert |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
private $title; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var Localized |
28
|
|
|
*/ |
29
|
|
|
private $titleLocalized; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
private $body; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var Localized |
38
|
|
|
*/ |
39
|
|
|
private $bodyLocalized; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var Localized |
43
|
|
|
*/ |
44
|
|
|
private $actionLocalized; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
private $launchImage = ''; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Constructor. |
53
|
|
|
* |
54
|
|
|
* @param string $body |
55
|
|
|
* @param string $title |
56
|
|
|
*/ |
57
|
|
|
public function __construct(string $body = '', string $title = '') |
58
|
|
|
{ |
59
|
|
|
$this->body = $body; |
60
|
|
|
$this->title = $title; |
61
|
|
|
$this->titleLocalized = new Localized(''); |
62
|
|
|
$this->bodyLocalized = new Localized(''); |
63
|
|
|
$this->actionLocalized = new Localized(''); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Set title |
68
|
|
|
* |
69
|
|
|
* @param string $title |
70
|
|
|
* |
71
|
|
|
* @return Alert |
72
|
|
|
*/ |
73
|
|
|
public function withTitle(string $title): Alert |
74
|
|
|
{ |
75
|
|
|
$cloned = clone $this; |
76
|
|
|
|
77
|
|
|
$cloned->title = $title; |
78
|
|
|
|
79
|
|
|
return $cloned; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* With localized title |
84
|
|
|
* |
85
|
|
|
* @param Localized $localized |
86
|
|
|
* |
87
|
|
|
* @return Alert |
88
|
|
|
*/ |
89
|
|
|
public function withLocalizedTitle(Localized $localized): Alert |
90
|
|
|
{ |
91
|
|
|
$cloned = clone $this; |
92
|
|
|
|
93
|
|
|
$cloned->titleLocalized = $localized; |
94
|
|
|
|
95
|
|
|
return $cloned; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Get title |
100
|
|
|
* |
101
|
|
|
* @return string |
102
|
|
|
*/ |
103
|
|
|
public function getTitle(): string |
104
|
|
|
{ |
105
|
|
|
return $this->title; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Get localized title |
110
|
|
|
* |
111
|
|
|
* @return Localized |
112
|
|
|
*/ |
113
|
|
|
public function getTitleLocalized(): Localized |
114
|
|
|
{ |
115
|
|
|
return $this->titleLocalized; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Set body |
120
|
|
|
* |
121
|
|
|
* @param string $body |
122
|
|
|
* |
123
|
|
|
* @return Alert |
124
|
|
|
*/ |
125
|
|
|
public function withBody(string $body): Alert |
126
|
|
|
{ |
127
|
|
|
$cloned = clone $this; |
128
|
|
|
|
129
|
|
|
$cloned->body = $body; |
130
|
|
|
|
131
|
|
|
return $cloned; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Set localized body |
136
|
|
|
* |
137
|
|
|
* @param Localized $localized |
138
|
|
|
* |
139
|
|
|
* @return Alert |
140
|
|
|
*/ |
141
|
|
|
public function withBodyLocalized(Localized $localized): Alert |
142
|
|
|
{ |
143
|
|
|
$cloned = clone $this; |
144
|
|
|
|
145
|
|
|
$cloned->bodyLocalized = $localized; |
146
|
|
|
|
147
|
|
|
return $cloned; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Get localized body |
152
|
|
|
* |
153
|
|
|
* @return Localized |
154
|
|
|
*/ |
155
|
|
|
public function getBodyLocalized(): Localized |
156
|
|
|
{ |
157
|
|
|
return $this->bodyLocalized; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Get body |
162
|
|
|
* |
163
|
|
|
* @return string |
164
|
|
|
*/ |
165
|
|
|
public function getBody(): string |
166
|
|
|
{ |
167
|
|
|
return $this->body; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* With localized action |
172
|
|
|
* |
173
|
|
|
* @param Localized $localized |
174
|
|
|
* |
175
|
|
|
* @return Alert |
176
|
|
|
*/ |
177
|
|
|
public function withActionLocalized(Localized $localized): Alert |
178
|
|
|
{ |
179
|
|
|
$cloned = clone $this; |
180
|
|
|
|
181
|
|
|
$cloned->actionLocalized = $localized; |
182
|
|
|
|
183
|
|
|
return $cloned; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Get localized action |
188
|
|
|
* |
189
|
|
|
* @return Localized |
190
|
|
|
*/ |
191
|
|
|
public function getActionLocalized(): Localized |
192
|
|
|
{ |
193
|
|
|
return $this->actionLocalized; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* Add launch image |
198
|
|
|
* |
199
|
|
|
* @param string $launchImage |
200
|
|
|
* |
201
|
|
|
* @return Alert |
202
|
|
|
*/ |
203
|
|
|
public function withLaunchImage(string $launchImage): Alert |
204
|
|
|
{ |
205
|
|
|
$cloned = clone $this; |
206
|
|
|
|
207
|
|
|
$cloned->launchImage = $launchImage; |
208
|
|
|
|
209
|
|
|
return $cloned; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Get launch image |
214
|
|
|
* |
215
|
|
|
* @return string |
216
|
|
|
*/ |
217
|
|
|
public function getLaunchImage(): string |
218
|
|
|
{ |
219
|
|
|
return $this->launchImage; |
220
|
|
|
} |
221
|
|
|
} |
222
|
|
|
|