This repository was archived by the owner on Feb 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ class Message implements Contracts\PushPayloadMakeable
12
12
13
13
/**
14
14
* Simple alert.
15
- * @var string
15
+ * @var string|array
16
16
*/
17
17
protected $ alert ;
18
18
@@ -36,24 +36,27 @@ class Message implements Contracts\PushPayloadMakeable
36
36
37
37
/**
38
38
* Create a push message.
39
- * @param null|string $alert
39
+ * @param null|string|array $alert
40
40
*/
41
- public function __construct (? string $ alert = null )
41
+ public function __construct ($ alert = null )
42
42
{
43
- if (is_string ($ alert )) {
43
+ if (is_string ($ alert ) || is_array ( $ alert ) ) {
44
44
$ this ->setAlert ($ alert );
45
45
}
46
46
}
47
47
48
48
/**
49
49
* Set simple alert.
50
- * @param string $alert
50
+ * @param string|array $alert
51
51
*/
52
52
public function setAlert (string $ alert )
53
53
{
54
- $ this ->alert = $ alert ;
54
+ if (is_string ($ alert ) || is_array ($ alert )) {
55
+ $ this ->alert = $ alert ;
56
+ return $ this ;
57
+ }
55
58
56
- return $ this ;
59
+ throw new \ Exception ( ' Alert 只允许字符串或者数组 ' ) ;
57
60
}
58
61
59
62
/**
@@ -72,11 +75,15 @@ public function setMessage(?string $contents = null, array $options) {
72
75
/**
73
76
* Set notifications.
74
77
* @param string $platform static::<IOS|ANDROID|WP>
75
- * @param string $alert
78
+ * @param string|array $alert
76
79
* @param array $options
77
80
*/
78
- public function setNotification (string $ platform , string $ alert , array $ options = [])
81
+ public function setNotification (string $ platform , $ alert , array $ options = [])
79
82
{
83
+ if (!is_array ($ alert ) || !is_array ($ alert )) {
84
+ throw new \Exception ('Alert 只允许字符串或者数组 ' );
85
+ }
86
+
80
87
$ this ->notifications [$ platform ] = [
81
88
'alert ' => $ alert ,
82
89
'options ' => $ options ,
You can’t perform that action at this time.
0 commit comments