1 | <?php |
||
10 | class NotificationBuilder |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * Indicates notification title. |
||
15 | * |
||
16 | * @var null|string |
||
17 | */ |
||
18 | protected $title; |
||
19 | |||
20 | /** |
||
21 | * Indicates notification body text. |
||
22 | * |
||
23 | * @var null|string |
||
24 | */ |
||
25 | protected $body; |
||
26 | |||
27 | /** |
||
28 | * Indicates a sound to play when the device receives a notification. |
||
29 | * |
||
30 | * @var null|string |
||
31 | */ |
||
32 | protected $sound; |
||
33 | |||
34 | /** |
||
35 | * Indicates the badge on the client app home icon. (iOS) |
||
36 | * |
||
37 | * @var null|string |
||
38 | */ |
||
39 | protected $badge; |
||
40 | |||
41 | /** |
||
42 | * Indicates notification icon. (Android) |
||
43 | * |
||
44 | * @var null|string |
||
45 | */ |
||
46 | protected $icon; |
||
47 | |||
48 | /** |
||
49 | * Indicates whether each notification results in a new entry in the |
||
50 | * notification drawer on Android. (Android) |
||
51 | * |
||
52 | * @var null|string |
||
53 | */ |
||
54 | protected $tag; |
||
55 | |||
56 | /** |
||
57 | * Indicates color of the icon, expressed in #rrggbb format. (Android) |
||
58 | * |
||
59 | * @var null|string |
||
60 | */ |
||
61 | protected $color; |
||
62 | |||
63 | /** |
||
64 | * Indicates the action associated with a user click on the notification. |
||
65 | * |
||
66 | * @var null|string |
||
67 | */ |
||
68 | protected $clickAction; |
||
69 | |||
70 | /** |
||
71 | * Indicates the key to the body string for localization. |
||
72 | * |
||
73 | * @var null|string |
||
74 | */ |
||
75 | protected $bodyLocKey; |
||
76 | |||
77 | /** |
||
78 | * Indicates the string value to replace format specifiers in the |
||
79 | * body string for localization. |
||
80 | * |
||
81 | * @var null|string |
||
82 | */ |
||
83 | protected $bodyLocArgs; |
||
84 | |||
85 | /** |
||
86 | * Indicates the key to the title string for localization. |
||
87 | * |
||
88 | * @var null|string |
||
89 | */ |
||
90 | protected $titleLocKey; |
||
91 | |||
92 | /** |
||
93 | * Indicates the string value to replace format specifiers in |
||
94 | * the title string for localization. |
||
95 | * |
||
96 | * @var null|string |
||
97 | */ |
||
98 | protected $titleLocArgs; |
||
99 | |||
100 | /** |
||
101 | * NotificationBuilder constructor. |
||
102 | * |
||
103 | * @param string $title Notification title. |
||
104 | */ |
||
105 | public function __construct($title) |
||
109 | |||
110 | /** |
||
111 | * Getter for title. |
||
112 | * |
||
113 | * @return null|string |
||
114 | */ |
||
115 | public function getTitle() |
||
119 | |||
120 | /** |
||
121 | * Getter for body. |
||
122 | * |
||
123 | * @return null|string |
||
124 | */ |
||
125 | public function getBody() |
||
129 | |||
130 | /** |
||
131 | * Setter for body. |
||
132 | * |
||
133 | * @param string $body Notification body text. |
||
134 | * @return $this |
||
135 | * @throws \ker0x\Push\Adapter\Fcm\Message\Exception\InvalidNotificationException |
||
136 | */ |
||
137 | public function setBody($body) |
||
144 | |||
145 | /** |
||
146 | * Getter for sound. |
||
147 | * |
||
148 | * @return null|string |
||
149 | */ |
||
150 | public function getSound() |
||
154 | |||
155 | /** |
||
156 | * Setter for sound. |
||
157 | * |
||
158 | * @param string $sound Sound to play when the device receives a notification. |
||
159 | * @return $this |
||
160 | * @throws \ker0x\Push\Adapter\Fcm\Message\Exception\InvalidNotificationException |
||
161 | */ |
||
162 | public function setSound($sound) |
||
169 | |||
170 | /** |
||
171 | * Getter for badge. |
||
172 | * |
||
173 | * @return null|string |
||
174 | */ |
||
175 | public function getBadge() |
||
179 | |||
180 | /** |
||
181 | * Setter for badge. |
||
182 | * |
||
183 | * @param string $badge Badge on the client app home icon. (iOS) |
||
184 | * @return $this |
||
185 | * @throws \ker0x\Push\Adapter\Fcm\Message\Exception\InvalidNotificationException |
||
186 | */ |
||
187 | public function setBadge($badge) |
||
194 | |||
195 | /** |
||
196 | * Getter for icon. |
||
197 | * |
||
198 | * @return null|string |
||
199 | */ |
||
200 | public function getIcon() |
||
204 | |||
205 | /** |
||
206 | * Setter for icon. |
||
207 | * |
||
208 | * @param string $icon Notification icon. (Android) |
||
209 | * @return $this |
||
210 | * @throws \ker0x\Push\Adapter\Fcm\Message\Exception\InvalidNotificationException |
||
211 | */ |
||
212 | public function setIcon($icon) |
||
219 | |||
220 | /** |
||
221 | * Getter for tag. |
||
222 | * |
||
223 | * @return null|string |
||
224 | */ |
||
225 | public function getTag() |
||
229 | |||
230 | /** |
||
231 | * Setter for tag. |
||
232 | * |
||
233 | * @param string $tag Notification results in a new entry in the |
||
234 | * notification drawer on Android. (Android) |
||
235 | * @return $this |
||
236 | * @throws \ker0x\Push\Adapter\Fcm\Message\Exception\InvalidNotificationException |
||
237 | */ |
||
238 | public function setTag($tag) |
||
245 | |||
246 | /** |
||
247 | * Getter for color. |
||
248 | * |
||
249 | * @return null|string |
||
250 | */ |
||
251 | public function getColor() |
||
255 | |||
256 | /** |
||
257 | * Setter for color. |
||
258 | * |
||
259 | * @param string $color Color of the icon, expressed in #rrggbb format. (Android) |
||
260 | * @return $this |
||
261 | * @throws \ker0x\Push\Adapter\Fcm\Message\Exception\InvalidNotificationException |
||
262 | */ |
||
263 | public function setColor($color) |
||
272 | |||
273 | /** |
||
274 | * Getter for clickAction. |
||
275 | * |
||
276 | * @return null|string |
||
277 | */ |
||
278 | public function getClickAction() |
||
282 | |||
283 | /** |
||
284 | * Setter for clickAction |
||
285 | * |
||
286 | * @param string $clickAction Action associated with a user click on the notification. |
||
287 | * @return $this |
||
288 | * @throws \ker0x\Push\Adapter\Fcm\Message\Exception\InvalidNotificationException |
||
289 | */ |
||
290 | public function setClickAction($clickAction) |
||
297 | |||
298 | /** |
||
299 | * Getter for bodyLocKey |
||
300 | * |
||
301 | * @return null|string |
||
302 | */ |
||
303 | public function getBodyLocKey() |
||
307 | |||
308 | /** |
||
309 | * Setter for bodyLocKey |
||
310 | * |
||
311 | * @param string $bodyLocKey Key to the body string for localization. |
||
312 | * @return $this |
||
313 | * @throws \ker0x\Push\Adapter\Fcm\Message\Exception\InvalidNotificationException |
||
314 | */ |
||
315 | public function setBodyLocKey($bodyLocKey) |
||
322 | |||
323 | /** |
||
324 | * Getter for bodyLocArgs. |
||
325 | * |
||
326 | * @return null|string |
||
327 | */ |
||
328 | public function getBodyLocArgs() |
||
332 | |||
333 | /** |
||
334 | * Setter for bodyLocArgs. |
||
335 | * |
||
336 | * @param string $bodyLocArgs String value to replace format specifiers in the |
||
337 | * body string for localization. |
||
338 | * @return $this |
||
339 | * @throws \ker0x\Push\Adapter\Fcm\Message\Exception\InvalidNotificationException |
||
340 | */ |
||
341 | public function setBodyLocArgs($bodyLocArgs) |
||
348 | |||
349 | /** |
||
350 | * Getter for titleLocKey. |
||
351 | * |
||
352 | * @return null|string |
||
353 | */ |
||
354 | public function getTitleLocKey() |
||
358 | |||
359 | /** |
||
360 | * Setter for titleLocKey. |
||
361 | * |
||
362 | * @param string $titleLocKey Key to the title string for localization. |
||
363 | * @return $this |
||
364 | * @throws \ker0x\Push\Adapter\Fcm\Message\Exception\InvalidNotificationException |
||
365 | */ |
||
366 | public function setTitleLocKey($titleLocKey) |
||
373 | |||
374 | /** |
||
375 | * Getter for titleLocArgs |
||
376 | * |
||
377 | * @return null|string |
||
378 | */ |
||
379 | public function getTitleLocArgs() |
||
383 | |||
384 | /** |
||
385 | * Setter for titleLocArgs |
||
386 | * |
||
387 | * @param string $titleLocArgs String value to replace format specifiers in |
||
388 | * the title string for localization. |
||
389 | * @return $this |
||
390 | * @throws \ker0x\Push\Adapter\Fcm\Message\Exception\InvalidNotificationException |
||
391 | */ |
||
392 | public function setTitleLocArgs($titleLocArgs) |
||
399 | |||
400 | /** |
||
401 | * Test if $value is a string. |
||
402 | * |
||
403 | * @param string $value The value to test. |
||
404 | * @param string $key The key of the value. |
||
405 | * @return void |
||
406 | * @throws \ker0x\Push\Adapter\Fcm\Message\Exception\InvalidNotificationException |
||
407 | */ |
||
408 | private function isString($value, $key) |
||
414 | } |
||
415 |