Test Failed
Push — master ( 7dd12d...2feef4 )
by Alexey
09:31 queued 11s
created

SlackMessage::getChannel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the WoW-Apps/Symfony-Slack-Bot bundle for Symfony.
5
 * https://github.com/wow-apps/symfony-slack-bot
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 * https://github.com/wow-apps/symfony-slack-bot/blob/master/LICENSE
10
 *
11
 * For technical documentation.
12
 * https://wow-apps.github.io/symfony-slack-bot/docs/
13
 *
14
 * Author Alexey Samara <[email protected]>
15
 *
16
 * Copyright 2016 WoW-Apps.
17
 */
18
19
namespace WowApps\SlackBundle\Entity;
20
21
/**
22
 * @author Alexey Samara <[email protected]>
23
 */
24
class SlackMessage
25
{
26
    /** @var string */
27
    private $username;
28
29
    /** @var string */
30
    private $channel;
31
32
    /** @var string */
33
    private $iconUrl;
34
35
    /** @var string */
36
    private $iconEmoji;
37
38
    /** @var bool */
39
    private $markdown;
40
41
    /** @var string */
42
    private $text;
43
44
    /** @var Attachment[] */
45
    private $attachments;
46
47
    /**
48
     * SlackMessage constructor.
49
     *
50
     * @param string $text
51
     * @param string $username
52
     * @param string $channel
53
     * @param string $iconUrl
54
     * @param string $iconEmoji
55
     * @param bool   $markdown
56
     * @param array  $attachments
57
     */
58
    public function __construct(
59
        string $text = '',
60
        string $username = '',
61
        string $channel = '',
62
        string $iconUrl = '',
63
        string $iconEmoji = '',
64
        bool   $markdown = true,
65
        array  $attachments = []
66
    ) {
67
        $this->text = $text;
68
        $this->username = $username;
69
        $this->channel = $channel;
70
        $this->iconUrl = $iconUrl;
71
        $this->iconEmoji = $iconEmoji;
72
        $this->markdown = $markdown;
73
        $this->attachments = $attachments;
74
    }
75
76
    /**
77
     * Returns the user name on behalf of which the message will be sent.
78
     *
79
     * @return string
80
     */
81
    public function getUsername(): string
82
    {
83
        return $this->username;
84
    }
85
86
    /**
87
     * Set the user name on behalf of which the message will be sent.
88
     *
89
     * @param string $username
90
     *
91
     * @return SlackMessage
92
     */
93
    public function setUsername(string $username): SlackMessage
94
    {
95
        $this->username = $username;
96
97
        return $this;
98
    }
99
100
    /**
101
     * Returns the name of channel where the message will be sent.
102
     *
103
     * @return string
104
     */
105
    public function getChannel(): string
106
    {
107
        return $this->channel;
108
    }
109
110
    /**
111
     * Set the name of channel where the message will be sent.
112
     *
113
     * @param string $channel
114
     *
115
     * @return SlackMessage
116
     */
117
    public function setChannel(string $channel): SlackMessage
118
    {
119
        $this->channel = $channel;
120
121
        return $this;
122
    }
123
124
    /**
125
     * Returns icon url of message.
126
     *
127
     * @return string
128
     */
129
    public function getIconUrl(): string
130
    {
131
        return $this->iconUrl;
132
    }
133
134
    /**
135
     * Set the icon url for a message.
136
     *
137
     * @param string $iconUrl
138
     *
139
     * @return SlackMessage
140
     */
141
    public function setIconUrl(string $iconUrl): SlackMessage
142
    {
143
        $this->iconUrl = $iconUrl;
144
145
        return $this;
146
    }
147
148
    /**
149
     * Returns icon Emoji of message.
150
     *
151
     * @return string
152
     */
153
    public function getIconEmoji(): string
154
    {
155
        return $this->iconEmoji;
156
    }
157
158
    /**
159
     * Set the icon Emoji for a message.
160
     *
161
     * @param string $iconEmoji
162
     *
163
     * @return SlackMessage
164
     */
165
    public function setIconEmoji(string $iconEmoji): SlackMessage
166
    {
167
        $this->iconEmoji = $iconEmoji;
168
169
        return $this;
170
    }
171
172
    /**
173
     * Returns state of markdown support of message.
174
     *
175
     * @return bool
176
     */
177
    public function isMarkdown(): bool
178
    {
179
        return $this->markdown;
180
    }
181
182
    /**
183
     * Set the state of markdown support of message.
184
     *
185
     * @param bool $markdown
186
     *
187
     * @return SlackMessage
188
     */
189
    public function setMarkdown(bool $markdown): SlackMessage
190
    {
191
        $this->markdown = $markdown;
192
193
        return $this;
194
    }
195
196
    /**
197
     * Returns main text of message.
198
     *
199
     * @return string
200
     */
201
    public function getText(): string
202
    {
203
        return $this->text;
204
    }
205
206
    /**
207
     * Set the main text of message.
208
     *
209
     * @param string $text
210
     *
211
     * @return SlackMessage
212
     */
213
    public function setText(string $text): SlackMessage
214
    {
215
        $this->text = $text;
216
217
        return $this;
218
    }
219
220
    /**
221
     * Returns collection of Attachment DTOs.
222
     *
223
     * @return Attachment[]
224
     */
225
    public function getAttachments(): array
226
    {
227
        return $this->attachments;
228
    }
229
230
    /**
231
     * Set collection of Attachment DTOs.
232
     *
233
     * @param Attachment[] $attachments
234
     *
235
     * @return SlackMessage
236
     */
237
    public function setAttachments(array $attachments): SlackMessage
238
    {
239
        $this->attachments = $attachments;
240
241
        return $this;
242
    }
243
244
    /**
245
     * Appends Attachment DTO to collection.
246
     *
247
     * @param Attachment $attachment
248
     *
249
     * @return SlackMessage
250
     */
251
    public function appendAttachment(Attachment $attachment): SlackMessage
252
    {
253
        if (empty($this->attachments)) {
254
            $this->attachments = [];
255
        }
256
257
        $this->attachments[] = $attachment;
258
259
        return $this;
260
    }
261
}
262