1 | <?php |
||
5 | class ApnMessage |
||
6 | { |
||
7 | /** |
||
8 | * The title of the notification. |
||
9 | * |
||
10 | * @var string |
||
11 | */ |
||
12 | public $title; |
||
13 | |||
14 | /** |
||
15 | * The body of the notification. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | public $body; |
||
20 | |||
21 | /** |
||
22 | * The badge of the notification. |
||
23 | * |
||
24 | * @var int |
||
25 | */ |
||
26 | public $badge; |
||
27 | |||
28 | /** |
||
29 | * The sound for the notification. |
||
30 | * |
||
31 | * @var string|null |
||
32 | */ |
||
33 | public $sound; |
||
34 | |||
35 | /** |
||
36 | * Additional data of the notification. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | public $custom = []; |
||
41 | |||
42 | /** |
||
43 | * @param string|null $title |
||
44 | * @param string|null $body |
||
45 | * @param array $custom |
||
46 | * @param null|int $badge |
||
47 | * |
||
48 | * @return static |
||
49 | */ |
||
50 | public static function create($title = null, $body = null, $custom = [], $badge = null) |
||
51 | { |
||
52 | return new static($title, $body, $custom, $badge); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @param string|null $title |
||
57 | * @param string|null $body |
||
58 | * @param array $custom |
||
59 | * @param null|int $badge |
||
60 | * |
||
61 | * @return static |
||
|
|||
62 | */ |
||
63 | 1 | public function __construct($title = null, $body = null, $custom = [], $badge = null) |
|
70 | |||
71 | /** |
||
72 | * Set the alert title of the notification. |
||
73 | * |
||
74 | * @param string $title |
||
75 | * |
||
76 | * @return $this |
||
77 | */ |
||
78 | public function title($title) |
||
84 | |||
85 | /** |
||
86 | * Set the alert message of the notification. |
||
87 | * |
||
88 | * @param string $body |
||
89 | * |
||
90 | * @return $this |
||
91 | */ |
||
92 | public function body($body) |
||
98 | |||
99 | /** |
||
100 | * Set the badge of the notification. |
||
101 | * |
||
102 | * @param int $badge |
||
103 | * |
||
104 | * @return $this |
||
105 | */ |
||
106 | public function badge($badge) |
||
112 | |||
113 | /** |
||
114 | * Set the sound for the notification. |
||
115 | * |
||
116 | * @param string|null $sound |
||
117 | * |
||
118 | * @return $this |
||
119 | */ |
||
120 | public function sound($sound) |
||
126 | |||
127 | /** |
||
128 | * Add custom data to the notification. |
||
129 | * |
||
130 | * @param string $key |
||
131 | * @param mixed $value |
||
132 | * |
||
133 | * @return $this |
||
134 | */ |
||
135 | public function custom($key, $value) |
||
141 | |||
142 | /** |
||
143 | * Override the data of the notification. |
||
144 | * |
||
145 | * @param array $custom |
||
146 | * |
||
147 | * @return $this |
||
148 | */ |
||
149 | public function setCustom($custom) |
||
155 | |||
156 | /** |
||
157 | * Add an action to the notification. |
||
158 | * |
||
159 | * @param string $action |
||
160 | * @param mixed $params |
||
161 | * |
||
162 | * @return $this |
||
163 | */ |
||
164 | public function action($action, $params = null) |
||
171 | } |
||
172 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.