1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NotificationChannels\IonicPushNotifications; |
4
|
|
|
|
5
|
|
|
class IonicPushMessage |
6
|
|
|
{ |
7
|
|
|
/** @var string */ |
8
|
|
|
protected $sendTo = 'tokens'; |
9
|
|
|
|
10
|
|
|
/** @var string */ |
11
|
|
|
protected $profile; |
12
|
|
|
|
13
|
|
|
/** @var string */ |
14
|
|
|
protected $title = ''; |
15
|
|
|
|
16
|
|
|
/** @var string */ |
17
|
|
|
protected $message = ''; |
18
|
|
|
|
19
|
|
|
/** @var string */ |
20
|
|
|
protected $sound = ''; |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
/** @var array */ |
24
|
|
|
protected $payload = []; |
25
|
|
|
|
26
|
|
|
/** @var array */ |
27
|
|
|
protected $iosData = []; |
28
|
|
|
|
29
|
|
|
/** @var array */ |
30
|
|
|
protected $androidData = []; |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param array $data |
|
|
|
|
36
|
|
|
* |
37
|
|
|
* @return static |
38
|
|
|
*/ |
39
|
|
|
public static function create($title, $message) |
40
|
|
|
{ |
41
|
|
|
return new static($title, $message); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param string $title |
46
|
|
|
* @param string $message |
47
|
|
|
*/ |
48
|
|
|
public function __construct($title, $message) |
49
|
|
|
{ |
50
|
|
|
$this->title = $title; |
51
|
|
|
$this->message = $message; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Set the security profile to use. |
56
|
|
|
* |
57
|
|
|
* @param string $profile |
58
|
|
|
* |
59
|
|
|
* @return $this |
60
|
|
|
*/ |
61
|
|
|
public function profile($profile) |
62
|
|
|
{ |
63
|
|
|
$this->profile = $profile; |
64
|
|
|
return $this; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Set the method of targeting users - tokens (default), user_ids, or emails. |
69
|
|
|
* |
70
|
|
|
* @param string $profile |
|
|
|
|
71
|
|
|
* |
72
|
|
|
* @return $this |
73
|
|
|
*/ |
74
|
|
|
public function sendTo($sendTo) |
75
|
|
|
{ |
76
|
|
|
$this->sendTo = $sendTo; |
77
|
|
|
return $this; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Set the security sound to use. |
82
|
|
|
* |
83
|
|
|
* @param string $sound |
84
|
|
|
* |
85
|
|
|
* @return $this |
86
|
|
|
*/ |
87
|
|
|
public function sound($sound) |
88
|
|
|
{ |
89
|
|
|
$this->sound = $sound; |
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Send custom key/value data with your notifications. |
95
|
|
|
* |
96
|
|
|
* @param array $payload |
97
|
|
|
* |
98
|
|
|
* @return $this |
99
|
|
|
*/ |
100
|
|
|
public function payload($payload) |
101
|
|
|
{ |
102
|
|
|
$this->payload = $payload; |
103
|
|
|
return $this; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Dynamically add query parameters or call API endpoints. |
109
|
|
|
* |
110
|
|
|
* @param string $method |
111
|
|
|
* @param array $args |
112
|
|
|
* |
113
|
|
|
* @return object |
114
|
|
|
*/ |
115
|
|
|
public function __call($method, $args) |
116
|
|
|
{ |
117
|
|
|
if (substr($method, 0, 3) == 'ios') { |
118
|
|
|
$key = snake_case(substr($method, 3)); |
119
|
|
|
|
120
|
|
|
$this->iosData[$key] = $args[0]; |
121
|
|
|
} elseif (substr($method, 0, 7) == 'android') { |
122
|
|
|
$key = snake_case(substr($method, 7)); |
123
|
|
|
|
124
|
|
|
$this->androidData[$key] = $args[0]; |
125
|
|
|
} |
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return array |
131
|
|
|
*/ |
132
|
|
|
public function toArray() |
133
|
|
|
{ |
134
|
|
|
return $this->data; |
|
|
|
|
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.