1 | <?php |
||
10 | class WebPushMessage |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $title; |
||
16 | |||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $actions = []; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $badge; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $body; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $dir; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $icon; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $image; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $lang; |
||
51 | |||
52 | /** |
||
53 | * @var bool |
||
54 | */ |
||
55 | protected $renotify; |
||
56 | |||
57 | /** |
||
58 | * @var bool |
||
59 | */ |
||
60 | protected $requireInteraction; |
||
61 | |||
62 | /** |
||
63 | * @var string |
||
64 | */ |
||
65 | protected $tag; |
||
66 | |||
67 | /** |
||
68 | * @var array |
||
69 | */ |
||
70 | protected $vibrate; |
||
71 | |||
72 | /** |
||
73 | * @var mixed |
||
74 | */ |
||
75 | protected $data; |
||
76 | |||
77 | /** |
||
78 | * @var array |
||
79 | */ |
||
80 | protected $options = []; |
||
81 | |||
82 | /** |
||
83 | * Set the notification title. |
||
84 | * |
||
85 | * @param string $value |
||
86 | * @return $this |
||
87 | */ |
||
88 | 3 | public function title($value) |
|
94 | |||
95 | /** |
||
96 | * Add a notification action. |
||
97 | * |
||
98 | * @param string $title |
||
99 | * @param string $action |
||
100 | * @param string $icon |
||
101 | * @return $this |
||
102 | */ |
||
103 | 3 | public function action($title, $action, $icon = null) |
|
109 | |||
110 | /** |
||
111 | * Set the notification badge. |
||
112 | * |
||
113 | * @param string $value |
||
114 | * @return $this |
||
115 | */ |
||
116 | 1 | public function badge($value) |
|
122 | |||
123 | /** |
||
124 | * Set the notification body. |
||
125 | * |
||
126 | * @param string $value |
||
127 | * @return $this |
||
128 | */ |
||
129 | 3 | public function body($value) |
|
135 | |||
136 | /** |
||
137 | * Set the notification direction. |
||
138 | * |
||
139 | * @param string $value |
||
140 | * @return $this |
||
141 | */ |
||
142 | 1 | public function dir($value) |
|
148 | |||
149 | /** |
||
150 | * Set the notification icon url. |
||
151 | * |
||
152 | * @param string $value |
||
153 | * @return $this |
||
154 | */ |
||
155 | 3 | public function icon($value) |
|
161 | |||
162 | /** |
||
163 | * Set the notification image url. |
||
164 | * |
||
165 | * @param string $value |
||
166 | * @return $this |
||
167 | */ |
||
168 | 1 | public function image($value) |
|
174 | |||
175 | /** |
||
176 | * Set the notification language. |
||
177 | * |
||
178 | * @param string $value |
||
179 | * @return $this |
||
180 | */ |
||
181 | 1 | public function lang($value) |
|
187 | |||
188 | /** |
||
189 | * @param bool $value |
||
190 | * @return $this |
||
191 | */ |
||
192 | 1 | public function renotify($value = true) |
|
198 | |||
199 | /** |
||
200 | * @param bool $value |
||
201 | * @return $this |
||
202 | */ |
||
203 | 1 | public function requireInteraction($value = true) |
|
209 | |||
210 | /** |
||
211 | * Set the notification tag. |
||
212 | * |
||
213 | * @param string $value |
||
214 | * @return $this |
||
215 | */ |
||
216 | 1 | public function tag($value) |
|
222 | |||
223 | /** |
||
224 | * Set the notification vibration pattern. |
||
225 | * |
||
226 | * @param array $value |
||
227 | * @return $this |
||
228 | */ |
||
229 | 1 | public function vibrate($value) |
|
235 | |||
236 | /** |
||
237 | * Set the notification arbitrary data. |
||
238 | * |
||
239 | * @param mixed $value |
||
240 | * @return $this |
||
241 | */ |
||
242 | 3 | public function data($value) |
|
248 | |||
249 | /** |
||
250 | * Set the notification options. |
||
251 | * |
||
252 | * @link https://github.com/web-push-libs/web-push-php#notifications-and-default-options |
||
253 | * |
||
254 | * @param array $value |
||
255 | * @return $this |
||
256 | */ |
||
257 | 3 | public function options(array $value) |
|
263 | |||
264 | /** |
||
265 | * Get the notification options. |
||
266 | * |
||
267 | * @return array |
||
268 | */ |
||
269 | 3 | public function getOptions() |
|
273 | |||
274 | /** |
||
275 | * Get an array representation of the message. |
||
276 | * |
||
277 | * @return array |
||
278 | */ |
||
279 | 16 | public function toArray() |
|
283 | } |
||
284 |