1 | <?php namespace nyx\notify\transports; |
||
15 | class Slack implements interfaces\Transport |
||
16 | { |
||
17 | /** |
||
18 | * The types Message icons can be of. |
||
19 | */ |
||
20 | const ICON_TYPE_URL = 'icon_url'; |
||
21 | const ICON_TYPE_EMOJI = 'icon_emoji'; |
||
22 | |||
23 | /** |
||
24 | * @var \GuzzleHttp\ClientInterface The underlying HTTP Client instance. |
||
25 | */ |
||
26 | protected $client; |
||
27 | |||
28 | /** |
||
29 | * @var string The oAuth token to authorize API requests with (when not using webhook endpoints). |
||
30 | */ |
||
31 | protected $token; |
||
32 | |||
33 | /** |
||
34 | * @var string The (Webhook) endpoint to send messages to (when not using the Web API). |
||
35 | */ |
||
36 | protected $endpoint; |
||
37 | |||
38 | /** |
||
39 | * @var string The default username to send messages as. |
||
40 | */ |
||
41 | protected $username; |
||
42 | |||
43 | /** |
||
44 | * @var string The default icon to send messages with. |
||
45 | */ |
||
46 | protected $icon; |
||
47 | |||
48 | /** |
||
49 | * @var string The default parse mode of Messages. One of the slack\Message::PARSE_* class constants. |
||
50 | */ |
||
51 | protected $parse; |
||
52 | |||
53 | /** |
||
54 | * @var bool Whether names (like @someone) should be linked or left raw by Slack. |
||
55 | */ |
||
56 | protected $linkNames; |
||
57 | |||
58 | /** |
||
59 | * @var bool Whether Slack should unfurl text-based URLs. |
||
60 | */ |
||
61 | protected $unfurlLinks; |
||
62 | |||
63 | /** |
||
64 | * @var bool Whether Slack should unfurl media URLs. |
||
65 | */ |
||
66 | protected $unfurlMedia; |
||
67 | |||
68 | /** |
||
69 | * @var bool Whether the text of the messages sent should be parsed as Slack's markdown flavour or treated as |
||
70 | * raw text. |
||
71 | */ |
||
72 | protected $allowMarkdown; |
||
73 | |||
74 | /** |
||
75 | * @var array The attachment fields that should be parsed by Slack's markdown flavour. |
||
76 | */ |
||
77 | protected $markdownInAttachments; |
||
78 | |||
79 | /** |
||
80 | * Parses an icon "definition" and determines whether it should be treated as an URL or a Slack-recognized |
||
81 | * emoji. |
||
82 | * |
||
83 | * @param string $icon The icon's "definition". |
||
84 | * @return string One of the ICON_TYPE_* class constants. |
||
85 | */ |
||
86 | public static function determineIconType(string $icon) : string |
||
95 | |||
96 | /** |
||
97 | * Constructs a new Slack Transport instance. |
||
98 | * |
||
99 | * @param array $config The Transport's configuration. |
||
100 | * @param \GuzzleHttp\ClientInterface $client A Guzzle HTTP Client instance. |
||
101 | * @todo Proper parsing of config options and error-recovery. |
||
102 | */ |
||
103 | public function __construct(array $config, \GuzzleHttp\ClientInterface $client) |
||
118 | |||
119 | /** |
||
120 | * {@inheritDoc} |
||
121 | * |
||
122 | * @throws \InvalidArgumentException When the Notification casts down to a Message without text nor attachments. |
||
123 | */ |
||
124 | public function send(interfaces\Notifiable $notifiable, interfaces\Notification $notification) |
||
173 | |||
174 | /** |
||
175 | * Performs the actual sending of a Message to a Slack Webhook endpoint. |
||
176 | * |
||
177 | * @param array $message The Message's data (toArray()'ed). |
||
178 | */ |
||
179 | protected function sendWebhookMessage(array $message) |
||
185 | |||
186 | /** |
||
187 | * Performs the actual sending of a Message to Slack's Web API. |
||
188 | * |
||
189 | * @param array $message The Message's data (toArray()'ed). |
||
190 | */ |
||
191 | protected function sendApiMessage(array $message) |
||
206 | |||
207 | /** |
||
208 | * Performs the actual sending of a Response to its Response URL provided by Slack. |
||
209 | * |
||
210 | * @param array $message The Message's data (toArray()'ed). |
||
211 | */ |
||
212 | protected function sendResponse(array $message) |
||
218 | |||
219 | /** |
||
220 | * {@inheritDoc} |
||
221 | */ |
||
222 | public function supports(interfaces\Notification $notification) : bool |
||
226 | } |
||
227 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: