1 | <?php |
||
14 | class FacebookMessage implements \JsonSerializable |
||
15 | { |
||
16 | use ButtonsTrait; |
||
17 | |||
18 | /** @var string Recipient's ID. */ |
||
19 | public $recipient; |
||
20 | |||
21 | /** @var string Notification Text. */ |
||
22 | public $text; |
||
23 | |||
24 | /** @var string Notification Type */ |
||
25 | public $notificationType = 'REGULAR'; |
||
26 | |||
27 | /** @var array Generic Template Cards (items) */ |
||
28 | public $cards = []; |
||
29 | |||
30 | /** @var string Notification Type */ |
||
31 | public $notification_type = NotificationType::REGULAR; |
||
32 | |||
33 | /** @var string Attachment Type |
||
34 | * Defaults to File |
||
35 | */ |
||
36 | public $attachment_type = AttachmentType::FILE; |
||
37 | |||
38 | /** @var string Attachment URL */ |
||
39 | public $attachment_url; |
||
40 | |||
41 | /** |
||
42 | * @var bool |
||
43 | */ |
||
44 | protected $has_attachment = false; |
||
45 | |||
46 | /** |
||
47 | * @var bool |
||
48 | */ |
||
49 | protected $has_text = false; |
||
50 | |||
51 | /** |
||
52 | * @param string $text |
||
53 | * |
||
54 | * @return static |
||
55 | */ |
||
56 | public static function create($text = '') |
||
57 | { |
||
58 | return new static($text); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @param string $text |
||
63 | */ |
||
64 | public function __construct($text = '') |
||
65 | { |
||
66 | if ($text != '') { |
||
67 | $this->text($text); |
||
68 | } |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Recipient's PSID or Phone Number. |
||
73 | * |
||
74 | * The id must be an ID that was retrieved through the |
||
75 | * Messenger entry points or through the Messenger webhooks. |
||
76 | * |
||
77 | * @param $recipient ID of recipient or Phone number of the recipient |
||
78 | * with the format +1(212)555-2368 |
||
79 | * |
||
80 | * @return $this |
||
81 | */ |
||
82 | public function to($recipient) |
||
88 | |||
89 | /** |
||
90 | * Notification text. |
||
91 | * |
||
92 | * @param $text |
||
93 | * @throws CouldNotCreateMessage |
||
94 | * |
||
95 | * @return $this |
||
96 | */ |
||
97 | public function text($text) |
||
108 | |||
109 | /** |
||
110 | * Add Attachment. |
||
111 | * |
||
112 | * @param $attachment_type |
||
113 | * @param $url |
||
114 | * @throws CouldNotCreateMessage |
||
115 | * |
||
116 | * @return $this |
||
117 | */ |
||
118 | public function attach($attachment_type, $url) |
||
138 | |||
139 | /** |
||
140 | * Push notification type. |
||
141 | * |
||
142 | * @param string $notificationType Possible values: REGULAR, SILENT_PUSH, NO_PUSH |
||
143 | * |
||
144 | * @return $this |
||
145 | */ |
||
146 | public function notificationType($notificationType = 'REGULAR') |
||
152 | |||
153 | /** |
||
154 | * Add up to 3 call to action buttons. |
||
155 | * |
||
156 | * @param array $buttons |
||
|
|||
157 | * |
||
158 | * @return $this |
||
159 | * @throws CouldNotSendNotification |
||
160 | */ |
||
161 | public function cards(array $cards = []) |
||
170 | |||
171 | /** |
||
172 | * Determine if user id is not given. |
||
173 | * |
||
174 | * @return bool |
||
175 | */ |
||
176 | public function toNotGiven() |
||
180 | |||
181 | /** |
||
182 | * Convert the object into something JSON serializable. |
||
183 | * |
||
184 | * @return array |
||
185 | */ |
||
186 | public function jsonSerialize() |
||
190 | |||
191 | /** |
||
192 | * Returns message payload for JSON conversion. |
||
193 | * @throws CouldNotCreateMessage |
||
194 | * @return array |
||
195 | */ |
||
196 | public function toArray() |
||
214 | |||
215 | /** |
||
216 | * Returns message for simple text message. |
||
217 | * @return array |
||
218 | */ |
||
219 | protected function textMessageToArray() |
||
228 | |||
229 | /** |
||
230 | * Returns message for attachment message. |
||
231 | * @return array |
||
232 | */ |
||
233 | protected function attachmentMessageToArray() |
||
243 | |||
244 | /** |
||
245 | * Returns message for Generic Template message. |
||
246 | * @return array |
||
247 | */ |
||
248 | protected function genericMessageToArray() |
||
259 | |||
260 | /** |
||
261 | * Returns message for Button Template message. |
||
262 | * @return array |
||
263 | */ |
||
264 | protected function buttonMessageToArray() |
||
276 | } |
||
277 |
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.