1 | <?php |
||
5 | class WebPushMessage |
||
6 | { |
||
7 | /** |
||
8 | * The notification id. |
||
9 | * |
||
10 | * @var string |
||
11 | */ |
||
12 | protected $id = null; |
||
13 | |||
14 | /** |
||
15 | * The notification title. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $title; |
||
20 | |||
21 | /** |
||
22 | * The notification body. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $body; |
||
27 | |||
28 | /** |
||
29 | * The notification icon. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $icon = null; |
||
34 | |||
35 | /** |
||
36 | * The notification actions. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $actions = []; |
||
41 | |||
42 | /** |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $data = []; |
||
47 | |||
48 | protected $image = null; |
||
49 | protected $badge = null; |
||
50 | protected $vibrate = [ ]; |
||
51 | protected $timestamp = null; |
||
52 | protected $tag = null; |
||
53 | |||
54 | /** |
||
55 | * @param string $body |
||
56 | * |
||
57 | * @return static |
||
58 | */ |
||
59 | 3 | public static function create($body = '') |
|
63 | |||
64 | /** |
||
65 | * @param string $body |
||
66 | */ |
||
67 | 9 | public function __construct($body = '') |
|
73 | |||
74 | /** |
||
75 | * Set the notification id. |
||
76 | * |
||
77 | * @param string $value |
||
78 | * @return $this |
||
79 | */ |
||
80 | 3 | public function id($value) |
|
86 | |||
87 | /** |
||
88 | * Set the notification title. |
||
89 | * |
||
90 | * @param string $value |
||
91 | * @return $this |
||
92 | */ |
||
93 | 3 | public function title($value) |
|
99 | |||
100 | /** |
||
101 | * Set the notification body. |
||
102 | * |
||
103 | * @param string $value |
||
104 | * @return $this |
||
105 | */ |
||
106 | 3 | public function body($value) |
|
112 | |||
113 | /** |
||
114 | * Set the notification icon. |
||
115 | * |
||
116 | * @param string $value |
||
117 | * @return $this |
||
118 | */ |
||
119 | 3 | public function icon($value) |
|
125 | |||
126 | /** |
||
127 | * Set an action. |
||
128 | * |
||
129 | * @param string $title |
||
130 | * @param string $action |
||
131 | * @return $this |
||
132 | */ |
||
133 | 3 | public function action($title, $action, $icon = null, $placeholder = null, $type = "button") |
|
139 | |||
140 | /** |
||
141 | * Set the arbitrary data payload. |
||
142 | * |
||
143 | * @param array $value |
||
144 | * @return $this |
||
145 | */ |
||
146 | public function data($value) |
||
152 | |||
153 | /** |
||
154 | * Set the badge. |
||
155 | * |
||
156 | * @param string $value |
||
157 | * @return $this |
||
158 | */ |
||
159 | public function badge($value) |
||
165 | |||
166 | /** |
||
167 | * Set the image. |
||
168 | * |
||
169 | * @param string $value |
||
170 | * @return $this |
||
171 | */ |
||
172 | public function image($value) |
||
178 | |||
179 | /** |
||
180 | * Set the vibrate pattern. |
||
181 | * |
||
182 | * @param array $value |
||
183 | * @return $this |
||
184 | */ |
||
185 | public function vibrate($value) |
||
191 | |||
192 | /** |
||
193 | * Set the timestamp pattern. |
||
194 | * |
||
195 | * @param int $value |
||
196 | * @return $this |
||
197 | */ |
||
198 | public function timestamp($value) |
||
204 | |||
205 | /** |
||
206 | * Set the tag pattern. |
||
207 | * |
||
208 | * @param string $value |
||
209 | * @return $this |
||
210 | */ |
||
211 | public function tag($value) |
||
217 | |||
218 | /** |
||
219 | * Get an array representation of the message. |
||
220 | * |
||
221 | * @return array |
||
222 | */ |
||
223 | 9 | public function toArray() |
|
242 | } |
||
243 |