1 | <?php |
||
8 | class PushoverMessage |
||
9 | { |
||
10 | /** |
||
11 | * The text content of the message. |
||
12 | * |
||
13 | * @var string |
||
14 | */ |
||
15 | public $content; |
||
16 | |||
17 | /** |
||
18 | * The (optional) title of the message. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | public $title; |
||
23 | |||
24 | /** |
||
25 | * The (optional) timestamp of the message. |
||
26 | * |
||
27 | * @var int |
||
28 | */ |
||
29 | public $timestamp; |
||
30 | |||
31 | /** |
||
32 | * The (optional) priority of the message. |
||
33 | * |
||
34 | * @var int |
||
35 | */ |
||
36 | public $priority; |
||
37 | |||
38 | /** |
||
39 | * The (optional) timeout between retries when sending a message |
||
40 | * with an emergency priority. The timeout is in seconds. |
||
41 | * |
||
42 | * @var int |
||
43 | */ |
||
44 | public $retry; |
||
45 | |||
46 | /** |
||
47 | * The (optional) expire time of a message with an emergency priority. |
||
48 | * The expire time is in seconds. |
||
49 | * |
||
50 | * @var int |
||
51 | */ |
||
52 | public $expire; |
||
53 | |||
54 | /** |
||
55 | * The (optional) supplementary url of the message. |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | public $url; |
||
60 | |||
61 | /** |
||
62 | * The (optional) supplementary url title of the message. |
||
63 | * |
||
64 | * @var string |
||
65 | */ |
||
66 | public $urlTitle; |
||
67 | |||
68 | /** |
||
69 | * The (optional) sound of the message. |
||
70 | * |
||
71 | * @var string |
||
72 | */ |
||
73 | public $sound; |
||
74 | |||
75 | /** |
||
76 | * Message priorities. |
||
77 | */ |
||
78 | const LOWEST_PRIORITY = -2; |
||
79 | const LOW_PRIORITY = -1; |
||
80 | const NORMAL_PRIORITY = 0; |
||
81 | const HIGH_PRIORITY = 1; |
||
82 | const EMERGENCY_PRIORITY = 2; |
||
83 | |||
84 | /** |
||
85 | * @param string $content |
||
86 | * |
||
87 | * @return static |
||
88 | */ |
||
89 | 2 | public static function create($content = '') |
|
93 | |||
94 | /** |
||
95 | * @param string $content |
||
96 | */ |
||
97 | 19 | public function __construct($content = '') |
|
101 | |||
102 | /** |
||
103 | * Set the content of the Pushover message. |
||
104 | * |
||
105 | * @param string $content |
||
106 | * @return $this |
||
107 | */ |
||
108 | 1 | public function content($content) |
|
114 | |||
115 | /** |
||
116 | * Set the title of the Pushover message. |
||
117 | * |
||
118 | * @param string $title |
||
119 | * @return $this |
||
120 | */ |
||
121 | 2 | public function title($title) |
|
127 | |||
128 | /** |
||
129 | * Set the time of the Pushover message. |
||
130 | * |
||
131 | * @param Carbon|int $time |
||
132 | * @return $this |
||
133 | */ |
||
134 | 3 | public function time($time) |
|
144 | |||
145 | /** |
||
146 | * Set a supplementary url for the Pushover message. |
||
147 | * |
||
148 | * @param string $url |
||
149 | * @param string $title |
||
150 | * @return $this |
||
151 | */ |
||
152 | 3 | public function url($url, $title = null) |
|
159 | |||
160 | /** |
||
161 | * Set the sound of the Pushover message. |
||
162 | * |
||
163 | * @param string $sound |
||
164 | * @return $this |
||
165 | */ |
||
166 | 2 | public function sound($sound) |
|
172 | |||
173 | /** |
||
174 | * Set the priority of the Pushover message. |
||
175 | * Retry and expire are mandatory when setting the priority to emergency. |
||
176 | * |
||
177 | * @param int $priority |
||
178 | * @param int $retryTimeout |
||
179 | * @param int $expireAfter |
||
180 | * @return $this |
||
181 | */ |
||
182 | 9 | public function priority($priority, $retryTimeout = null, $expireAfter = null) |
|
192 | |||
193 | /** |
||
194 | * Set the priority of the Pushover message to the lowest priority. |
||
195 | * |
||
196 | * @return $this |
||
197 | */ |
||
198 | 1 | public function lowestPriority() |
|
202 | |||
203 | /** |
||
204 | * Set the priority of the Pushover message to low. |
||
205 | * |
||
206 | * @return $this |
||
207 | */ |
||
208 | 1 | public function lowPriority() |
|
212 | |||
213 | /** |
||
214 | * Set the priority of the Pushover message to normal. |
||
215 | * |
||
216 | * @return $this |
||
217 | */ |
||
218 | 1 | public function normalPriority() |
|
222 | |||
223 | /** |
||
224 | * Set the priority of the Pushover message to high. |
||
225 | * |
||
226 | * @return $this |
||
227 | */ |
||
228 | 1 | public function highPriority() |
|
232 | |||
233 | /** |
||
234 | * Set the priority of the Pushover message to emergency. |
||
235 | * Retry and expire are mandatory when setting the priority to emergency. |
||
236 | * |
||
237 | * @param int $retryTimeout |
||
238 | * @param int $expireAfter |
||
239 | * @return $this |
||
240 | */ |
||
241 | 2 | public function emergencyPriority($retryTimeout, $expireAfter) |
|
245 | |||
246 | /** |
||
247 | * Array representation of Pushover Message. |
||
248 | * |
||
249 | * @return array |
||
250 | */ |
||
251 | public function toArray() |
||
265 | |||
266 | /** |
||
267 | * Ensure an emergency message has an retry and expiry time. |
||
268 | * |
||
269 | * @param int $priority |
||
270 | * @param int $retry |
||
271 | * @param int $expire |
||
272 | * @throws EmergencyNotificationRequiresRetryAndExpire |
||
273 | */ |
||
274 | protected function noEmergencyWithoutRetryOrExpire($priority, $retry, $expire) |
||
280 | } |
||
281 |