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 | 4 | public function title($value) |
|
94 | |||
95 | /** |
||
96 | * Add a notification action. |
||
97 | * |
||
98 | * @param string $title |
||
99 | * @param string $action |
||
100 | * @return $this |
||
101 | */ |
||
102 | 4 | public function action($title, $action) |
|
108 | |||
109 | /** |
||
110 | * Set the notification badge. |
||
111 | * |
||
112 | * @param string $value |
||
113 | * @return $this |
||
114 | */ |
||
115 | 1 | public function badge($value) |
|
121 | |||
122 | /** |
||
123 | * Set the notification body. |
||
124 | * |
||
125 | * @param string $value |
||
126 | * @return $this |
||
127 | */ |
||
128 | 4 | public function body($value) |
|
134 | |||
135 | /** |
||
136 | * Set the notification direction. |
||
137 | * |
||
138 | * @param string $value |
||
139 | * @return $this |
||
140 | */ |
||
141 | 1 | public function dir($value) |
|
147 | |||
148 | /** |
||
149 | * Set the notification icon url. |
||
150 | * |
||
151 | * @param string $value |
||
152 | * @return $this |
||
153 | */ |
||
154 | 4 | public function icon($value) |
|
160 | |||
161 | /** |
||
162 | * Set the notification image url. |
||
163 | * |
||
164 | * @param string $value |
||
165 | * @return $this |
||
166 | */ |
||
167 | 1 | public function image($value) |
|
173 | |||
174 | /** |
||
175 | * Set the notification language. |
||
176 | * |
||
177 | * @param string $value |
||
178 | * @return $this |
||
179 | */ |
||
180 | 1 | public function lang($value) |
|
186 | |||
187 | /** |
||
188 | * @param bool $value |
||
189 | * @return $this |
||
190 | */ |
||
191 | 1 | public function renotify($value = true) |
|
197 | |||
198 | /** |
||
199 | * @param bool $value |
||
200 | * @return $this |
||
201 | */ |
||
202 | 1 | public function requireInteraction($value = true) |
|
208 | |||
209 | /** |
||
210 | * Set the notification tag. |
||
211 | * |
||
212 | * @param string $value |
||
213 | * @return $this |
||
214 | */ |
||
215 | 1 | public function tag($value) |
|
221 | |||
222 | /** |
||
223 | * Set the notification vibration pattern. |
||
224 | * |
||
225 | * @param array $value |
||
226 | * @return $this |
||
227 | */ |
||
228 | 1 | public function vibrate($value) |
|
234 | |||
235 | /** |
||
236 | * Set the notification arbitrary data. |
||
237 | * |
||
238 | * @param mixed $value |
||
239 | * @return $this |
||
240 | */ |
||
241 | 4 | public function data($value) |
|
247 | |||
248 | /** |
||
249 | * Set the notification options. |
||
250 | * |
||
251 | * @link https://github.com/web-push-libs/web-push-php#notifications-and-default-options |
||
252 | * |
||
253 | * @param array $value |
||
254 | * @return $this |
||
255 | */ |
||
256 | 2 | public function options(array $value) |
|
262 | |||
263 | /** |
||
264 | * Get the notification options. |
||
265 | * |
||
266 | * @return array |
||
267 | */ |
||
268 | 4 | public function getOptions() |
|
272 | |||
273 | /** |
||
274 | * Get an array representation of the message. |
||
275 | * |
||
276 | * @return array |
||
277 | */ |
||
278 | 17 | public function toArray() |
|
282 | } |
||
283 |