1 | <?php |
||
22 | class SlackTarget extends Target |
||
23 | { |
||
24 | /** |
||
25 | * Yii HTTP client configuration. |
||
26 | * This can be a component ID, a configuration array or a Client instance. |
||
27 | * |
||
28 | * @var Client|array|string |
||
29 | * @since 1.2 |
||
30 | */ |
||
31 | public $httpClient = [ |
||
32 | 'class' => 'yii\httpclient\Client' |
||
33 | ]; |
||
34 | |||
35 | /** |
||
36 | * Incoming Webhook URL. |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | public $webhookUrl; |
||
41 | |||
42 | /** |
||
43 | * Displayed username. |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | public $username; |
||
48 | |||
49 | /** |
||
50 | * Icon URL. |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | public $iconUrl; |
||
55 | |||
56 | /** |
||
57 | * Icon Emoji. |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | public $iconEmoji; |
||
62 | |||
63 | /** |
||
64 | * Channel or Direct Message. |
||
65 | * |
||
66 | * @var string |
||
67 | */ |
||
68 | public $channel; |
||
69 | |||
70 | /** |
||
71 | * Colors per a Logger level. |
||
72 | * |
||
73 | * @var array |
||
74 | */ |
||
75 | public $colors = [ |
||
76 | Logger::LEVEL_ERROR => 'danger', |
||
77 | Logger::LEVEL_WARNING => 'warning' |
||
78 | ]; |
||
79 | |||
80 | /** |
||
81 | * @inheritDoc |
||
82 | */ |
||
83 | public $exportInterval = 50; |
||
84 | |||
85 | /** |
||
86 | * @inheritDoc |
||
87 | */ |
||
88 | 5 | public function init() |
|
93 | |||
94 | /** |
||
95 | * @inheritDoc |
||
96 | */ |
||
97 | 1 | public function export() |
|
110 | |||
111 | /** |
||
112 | * Encodes special chars in a message as HTML entities. |
||
113 | * |
||
114 | * @param string $message |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | 4 | protected function encodeMessage($message) |
|
122 | |||
123 | /** |
||
124 | * Returns a Slack API payload. |
||
125 | * |
||
126 | * @return array |
||
127 | * @since 1.2 |
||
128 | */ |
||
129 | 2 | protected function getPayload() |
|
141 | |||
142 | /** |
||
143 | * Returns a properly formatted message attachment for Slack API. |
||
144 | * |
||
145 | * @param array $message |
||
146 | * |
||
147 | * @return array |
||
148 | */ |
||
149 | 3 | protected function formatMessageAttachment($message) |
|
202 | |||
203 | /** |
||
204 | * Inserts session data into the attachement if applicable. |
||
205 | * |
||
206 | * @param array $attachment |
||
207 | */ |
||
208 | 3 | private function insertSessionIntoAttachment(array &$attachment) |
|
222 | |||
223 | /** |
||
224 | * Inserts traces into the attachement if applicable. |
||
225 | * |
||
226 | * @param array $traces |
||
227 | * @param array $attachment |
||
228 | */ |
||
229 | private function insertTracesIntoAttachment(array $traces, array &$attachment) |
||
240 | |||
241 | /** |
||
242 | * Inserts user data into the attachement if applicable. |
||
243 | * |
||
244 | * @param array $attachment |
||
245 | */ |
||
246 | 3 | private function insertUserIntoAttachment(array &$attachment) |
|
259 | |||
260 | /** |
||
261 | * Inserts request data into the attachement if applicable. |
||
262 | * |
||
263 | * @param array $attachment |
||
264 | */ |
||
265 | 4 | private function insertRequestIntoAttachment(array &$attachment) |
|
283 | |||
284 | /** |
||
285 | * Copies the value to the payload if the value is set. |
||
286 | * |
||
287 | * @param array $payload |
||
288 | * @param string $name |
||
289 | * @param mixed $value |
||
290 | */ |
||
291 | 2 | private function insertIntoPayload(array &$payload, $name, $value) |
|
297 | } |
||
298 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: