GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 9be716...8dfb79 )
by Cas
10:46 queued 07:19
created

ChatPostMessagePayload::setIconEmoji()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.1481

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 4
cts 6
cp 0.6667
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2.1481
1
<?php
2
3
/*
4
 * This file is part of the Slack API library.
5
 *
6
 * (c) Cas Leentfaar <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CL\Slack\Payload;
13
14
use CL\Slack\Model\Attachment;
15
use Doctrine\Common\Collections\ArrayCollection;
16
use JMS\Serializer\Serializer;
17
18
/**
19
 * @author Cas Leentfaar <[email protected]>
20
 *
21
 * @link Official documentation at https://api.slack.com/methods/chat.postMessage
22
 */
23
class ChatPostMessagePayload extends AbstractPayload implements AdvancedSerializeInterface
24
{
25
    /**
26
     * @var string
27
     */
28
    private $channel;
29
30
    /**
31
     * @var string
32
     */
33
    private $text;
34
35
    /**
36
     * @var string
37
     */
38
    private $username;
39
40
    /**
41
     * @var string
42
     */
43
    private $iconEmoji;
44
45
    /**
46
     * @var string
47
     */
48
    private $iconUrl;
49
50
    /**
51
     * @var bool
52
     */
53
    private $unfurlLinks;
54
55
    /**
56
     * @var bool
57
     */
58
    private $unfurlMedia;
59
60
    /**
61
     * @var bool
62
     */
63
    private $linkNames;
64
65
    /**
66
     * @var string
67
     */
68
    private $parse;
69
70
    /**
71
     * @var Attachment[]|ArrayCollection
72
     */
73
    private $attachments;
74
75
    /**
76
     * @var string
77
     */
78
    private $attachmentsJson;
79
80 1
    public function __construct()
81
    {
82 1
        $this->attachments = new ArrayCollection();
83 1
    }
84
85
    /**
86
     * Sets the channel to send the message to.
87
     * Can be a public channel, private group, IM channel, encoded ID, or a name.
88
     *
89
     * @param string $channel
90
     */
91 1
    public function setChannel($channel)
92
    {
93 1
        $this->channel = $channel;
94 1
    }
95
96
    /**
97
     * @return string The channel to send the message to.
98
     */
99 1
    public function getChannel()
100
    {
101 1
        return $this->channel;
102
    }
103
104
    /**
105
     * @param string $text Actual message to send.
106
     *
107
     * @see https://api.slack.com/docs/formatting for an explanation of formatting.
108
     */
109 1
    public function setText($text)
110
    {
111 1
        $this->text = $text;
112 1
    }
113
114
    /**
115
     * @return string Actual message to send.
116
     */
117 1
    public function getText()
118
    {
119 1
        return $this->text;
120
    }
121
122
    /**
123
     * @param string $message
124
     *
125
     * @deprecated Will be removed soon, use `setText()` instead
126
     */
127
    public function setMessage($message)
128
    {
129
        $this->setText($message);
130
    }
131
132
    /**
133
     * @return string
134
     *
135
     * @deprecated Will be removed soon, use `getText()` instead
136
     */
137
    public function getMessage()
138
    {
139
        return $this->getText();
140
    }
141
142
    /**
143
     * @param string $username Name of bot that will send the message (can be any name you want).
144
     */
145 1
    public function setUsername($username)
146
    {
147 1
        $this->username = $username;
148 1
    }
149
150
    /**
151
     * @return string Name of the bot that will send the message.
152
     */
153 1
    public function getUsername()
154
    {
155 1
        return $this->username;
156
    }
157
158
    /**
159
     * @param string $parse Change how messages are treated.
160
     *
161
     * @see https://api.slack.com/docs/formatting
162
     */
163 1
    public function setParse($parse)
164
    {
165 1
        $this->parse = $parse;
166 1
    }
167
168
    /**
169
     * @return string Change how messages are treated.
170
     */
171 1
    public function getParse()
172
    {
173 1
        return $this->parse;
174
    }
175
176
    /**
177
     * Sets the emoji to use as the icon for this message (overrides icon URL).
178
     *
179
     * You can use one of Slack's emoji's or upload your own.
180
     *
181
     * @see https://{YOURSLACKTEAMHERE}.slack.com/customize/emoji
182
     *
183
     * @param string|null $iconEmoji Emoji to use as the icon for this message (overrides icon URL).
184
     */
185 1
    public function setIconEmoji($iconEmoji)
186
    {
187 1
        if (substr($iconEmoji, 0, 1) !== ':') {
188
            $iconEmoji = sprintf(':%s:', $iconEmoji);
189
        }
190
191 1
        $this->iconEmoji = $iconEmoji;
192 1
    }
193
194
    /**
195
     * @return string|null Emoji to use as the icon for this message.
196
     */
197 1
    public function getIconEmoji()
198
    {
199 1
        return $this->iconEmoji;
200
    }
201
202
    /**
203
     * @param string|null $iconUrl URL to an image to use as the icon for this message.
204
     */
205 1
    public function setIconUrl($iconUrl)
206
    {
207 1
        $this->iconUrl = $iconUrl;
208 1
    }
209
210
    /**
211
     * @return string|null URL to an image to use as the icon for this message.
212
     */
213 1
    public function getIconUrl()
214
    {
215 1
        return $this->iconUrl;
216
    }
217
218
    /**
219
     * By default links to media are unfurled, but links to text content are not.
220
     * For more information on the differences and how to control this, see the the unfurling documentation.
221
     *
222
     * @see https://api.slack.com/docs/unfurling
223
     *
224
     * @param bool $unfurlLinks Pass true to enable unfurling of primarily text-based content.
225
     */
226 1
    public function setUnfurlLinks($unfurlLinks)
227
    {
228 1
        $this->unfurlLinks = $unfurlLinks;
229 1
    }
230
231
    /**
232
     * @return bool|null
233
     */
234 1
    public function getUnfurlLinks()
235
    {
236 1
        return $this->unfurlLinks;
237
    }
238
239
    /**
240
     * @see https://api.slack.com/docs/unfurling
241
     *
242
     * @param bool $unfurlMedia Pass false to disable unfurling of media content.
243
     */
244 1
    public function setUnfurlMedia($unfurlMedia)
245
    {
246 1
        $this->unfurlMedia = $unfurlMedia;
247 1
    }
248
249
    /**
250
     * @return bool|null
251
     */
252 1
    public function getUnfurlMedia()
253
    {
254 1
        return $this->unfurlMedia;
255
    }
256
257
    /**
258
     * @param bool $linkNames Set to true to automatically find and link channel names and usernames in the message.
259
     */
260 1
    public function setLinkNames($linkNames)
261
    {
262 1
        $this->linkNames = $linkNames;
263 1
    }
264
265
    /**
266
     * @see https://api.slack.com/docs/unfurling
267
     *
268
     * @return bool|null Whether channel names and usernames in the message should be linked automatically.
269
     */
270 1
    public function getLinkNames()
271
    {
272 1
        return $this->linkNames;
273
    }
274
275
    /**
276
     * @return Attachment[]|ArrayCollection
277
     */
278 1
    public function getAttachments()
279
    {
280 1
        return $this->attachments;
281
    }
282
283
    /**
284
     * @param Attachment $attachment
285
     */
286 1
    public function addAttachment(Attachment $attachment)
287
    {
288 1
        $this->attachments->add($attachment);
289 1
    }
290
291
    /**
292
     * Use for serialization.
293
     *
294
     * @return string
295
     */
296 1
    public function getAttachmentsJson()
297
    {
298 1
        return $this->attachmentsJson;
299
    }
300
301
    /**
302
     * {@inheritdoc}
303
     */
304 1
    public function getMethod()
305
    {
306 1
        return 'chat.postMessage';
307
    }
308
309
    /**
310
     * {@inheritdoc}
311
     */
312 1
    public function beforeSerialize(Serializer $serializer)
313
    {
314 1
        $this->attachmentsJson = $serializer->serialize($this->attachments, 'json');
315 1
    }
316
}
317