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 format of the message. |
||
19 | * |
||
20 | * Either "plain", "html" or "monospace". |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | public $format = self::FORMAT_PLAIN; |
||
25 | |||
26 | /** |
||
27 | * The (optional) title of the message. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | public $title; |
||
32 | |||
33 | /** |
||
34 | * The (optional) timestamp of the message. |
||
35 | * |
||
36 | * @var int |
||
37 | */ |
||
38 | public $timestamp; |
||
39 | |||
40 | /** |
||
41 | * The (optional) priority of the message. |
||
42 | * |
||
43 | * @var int |
||
44 | */ |
||
45 | public $priority; |
||
46 | |||
47 | /** |
||
48 | * The (optional) timeout between retries when sending a message |
||
49 | * with an emergency priority. The timeout is in seconds. |
||
50 | * |
||
51 | * @var int |
||
52 | */ |
||
53 | public $retry; |
||
54 | |||
55 | /** |
||
56 | * The (optional) expire time of a message with an emergency priority. |
||
57 | * The expire time is in seconds. |
||
58 | * |
||
59 | * @var int |
||
60 | */ |
||
61 | public $expire; |
||
62 | |||
63 | /** |
||
64 | * The (optional) supplementary url of the message. |
||
65 | * |
||
66 | * @var string |
||
67 | */ |
||
68 | public $url; |
||
69 | |||
70 | /** |
||
71 | * The (optional) supplementary url title of the message. |
||
72 | * |
||
73 | * @var string |
||
74 | */ |
||
75 | public $urlTitle; |
||
76 | |||
77 | /** |
||
78 | * The (optional) sound of the message. |
||
79 | * |
||
80 | * @var string |
||
81 | */ |
||
82 | public $sound; |
||
83 | |||
84 | /** |
||
85 | * Message formats. |
||
86 | */ |
||
87 | const FORMAT_PLAIN = 0; |
||
88 | const FORMAT_HTML = 1; |
||
89 | const FORMAT_MONOSPACE = 2; |
||
90 | |||
91 | /** |
||
92 | * Message priorities. |
||
93 | */ |
||
94 | const LOWEST_PRIORITY = -2; |
||
95 | const LOW_PRIORITY = -1; |
||
96 | const NORMAL_PRIORITY = 0; |
||
97 | const HIGH_PRIORITY = 1; |
||
98 | const EMERGENCY_PRIORITY = 2; |
||
99 | |||
100 | /** |
||
101 | * @param string $content |
||
102 | * |
||
103 | * @return static |
||
104 | */ |
||
105 | 2 | public static function create($content = '') |
|
109 | |||
110 | /** |
||
111 | * @param string $content |
||
112 | */ |
||
113 | 23 | public function __construct($content = '') |
|
117 | |||
118 | /** |
||
119 | * Set the content of the Pushover message. |
||
120 | * |
||
121 | * @param string $content |
||
122 | * @return $this |
||
123 | */ |
||
124 | 1 | public function content($content) |
|
130 | |||
131 | /** |
||
132 | * Set the formatting type to plain text. |
||
133 | * |
||
134 | * @return $this |
||
135 | */ |
||
136 | 1 | public function plain() |
|
142 | |||
143 | /** |
||
144 | * Set the formatting type to HTML. |
||
145 | * |
||
146 | * @return $this |
||
147 | */ |
||
148 | 2 | public function html() |
|
154 | |||
155 | /** |
||
156 | * Set the formatting type to monospace. |
||
157 | * |
||
158 | * @return $this |
||
159 | */ |
||
160 | 1 | public function monospace() |
|
166 | |||
167 | /** |
||
168 | * Set the title of the Pushover message. |
||
169 | * |
||
170 | * @param string $title |
||
171 | * @return $this |
||
172 | */ |
||
173 | 3 | public function title($title) |
|
179 | |||
180 | /** |
||
181 | * Set the time of the Pushover message. |
||
182 | * |
||
183 | * @param Carbon|int $time |
||
184 | * @return $this |
||
185 | */ |
||
186 | 4 | public function time($time) |
|
196 | |||
197 | /** |
||
198 | * Set a supplementary url for the Pushover message. |
||
199 | * |
||
200 | * @param string $url |
||
201 | * @param string $title |
||
202 | * @return $this |
||
203 | */ |
||
204 | 4 | public function url($url, $title = null) |
|
211 | |||
212 | /** |
||
213 | * Set the sound of the Pushover message. |
||
214 | * |
||
215 | * @param string $sound |
||
216 | * @return $this |
||
217 | */ |
||
218 | 3 | public function sound($sound) |
|
224 | |||
225 | /** |
||
226 | * Set the priority of the Pushover message. |
||
227 | * Retry and expire are mandatory when setting the priority to emergency. |
||
228 | * |
||
229 | * @param int $priority |
||
230 | * @param int $retryTimeout |
||
231 | * @param int $expireAfter |
||
232 | * @return $this |
||
233 | */ |
||
234 | 10 | public function priority($priority, $retryTimeout = null, $expireAfter = null) |
|
244 | |||
245 | /** |
||
246 | * Set the priority of the Pushover message to the lowest priority. |
||
247 | * |
||
248 | * @return $this |
||
249 | */ |
||
250 | 1 | public function lowestPriority() |
|
254 | |||
255 | /** |
||
256 | * Set the priority of the Pushover message to low. |
||
257 | * |
||
258 | * @return $this |
||
259 | */ |
||
260 | 1 | public function lowPriority() |
|
264 | |||
265 | /** |
||
266 | * Set the priority of the Pushover message to normal. |
||
267 | * |
||
268 | * @return $this |
||
269 | */ |
||
270 | 1 | public function normalPriority() |
|
274 | |||
275 | /** |
||
276 | * Set the priority of the Pushover message to high. |
||
277 | * |
||
278 | * @return $this |
||
279 | */ |
||
280 | 1 | public function highPriority() |
|
284 | |||
285 | /** |
||
286 | * Set the priority of the Pushover message to emergency. |
||
287 | * Retry and expire are mandatory when setting the priority to emergency. |
||
288 | * |
||
289 | * @param int $retryTimeout |
||
290 | * @param int $expireAfter |
||
291 | * @return $this |
||
292 | */ |
||
293 | 3 | public function emergencyPriority($retryTimeout, $expireAfter) |
|
297 | |||
298 | /** |
||
299 | * Array representation of Pushover Message. |
||
300 | * |
||
301 | * @return array |
||
302 | */ |
||
303 | 2 | public function toArray() |
|
319 | |||
320 | /** |
||
321 | * Ensure an emergency message has an retry and expiry time. |
||
322 | * |
||
323 | * @param int $priority |
||
324 | * @param int $retry |
||
325 | * @param int $expire |
||
326 | * @throws EmergencyNotificationRequiresRetryAndExpire |
||
327 | */ |
||
328 | 10 | protected function noEmergencyWithoutRetryOrExpire($priority, $retry, $expire) |
|
334 | } |
||
335 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.