1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WowApps\SlackBotBundle\DTO; |
4
|
|
|
|
5
|
|
|
use WowApps\SlackBotBundle\Traits\SlackMessageTrait; |
6
|
|
|
|
7
|
|
|
class SlackMessage |
8
|
|
|
{ |
9
|
|
|
use SlackMessageTrait; |
10
|
|
|
|
11
|
|
|
/** @var string */ |
12
|
|
|
private $icon; |
13
|
|
|
|
14
|
|
|
/** @var string */ |
15
|
|
|
private $text; |
16
|
|
|
|
17
|
|
|
/** @var int */ |
18
|
|
|
private $quoteType; |
19
|
|
|
|
20
|
|
|
/** @var string */ |
21
|
|
|
private $quoteTitle; |
22
|
|
|
|
23
|
|
|
/** @var string */ |
24
|
|
|
private $quoteTitleLink; |
25
|
|
|
|
26
|
|
|
/** @var string */ |
27
|
|
|
private $quoteText; |
28
|
|
|
|
29
|
|
|
/** @var bool */ |
30
|
|
|
private $showQuote; |
31
|
|
|
|
32
|
|
|
/** @var string */ |
33
|
|
|
private $recipient; |
34
|
|
|
|
35
|
|
|
/** @var string */ |
36
|
|
|
private $sender; |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* SlackMessage constructor. |
41
|
|
|
* @param string $icon |
42
|
|
|
* @param string $text |
43
|
|
|
* @param int $quoteType |
44
|
|
|
* @param string $quoteTitle |
45
|
|
|
* @param string $quoteTitleLink |
46
|
|
|
* @param string $quoteText |
47
|
|
|
* @param bool $showQuote |
48
|
|
|
* @param string $recipient |
49
|
|
|
* @param string $sender |
50
|
|
|
*/ |
51
|
|
|
public function __construct( |
52
|
|
|
string $icon = '', |
53
|
|
|
string $text = '', |
54
|
|
|
int $quoteType = 0, |
55
|
|
|
string $quoteTitle = '', |
56
|
|
|
string $quoteTitleLink = '', |
57
|
|
|
string $quoteText = '', |
58
|
|
|
bool $showQuote = false, |
59
|
|
|
string $recipient = '', |
60
|
|
|
string $sender = '' |
61
|
|
|
) { |
62
|
|
|
$this |
63
|
|
|
->setIcon($icon) |
64
|
|
|
->setText($text) |
65
|
|
|
->setQuoteType($quoteType) |
66
|
|
|
->setQuoteTitle($quoteTitle) |
67
|
|
|
->setQuoteTitleLink($quoteTitleLink) |
68
|
|
|
->setQuoteText($quoteText) |
69
|
|
|
->setShowQuote($showQuote) |
70
|
|
|
->setRecipient($recipient) |
71
|
|
|
->setSender($sender) |
72
|
|
|
; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return string |
77
|
|
|
*/ |
78
|
|
|
public function getIcon(): string |
79
|
|
|
{ |
80
|
|
|
return $this->icon; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param string $icon |
85
|
|
|
* @return SlackMessage |
86
|
|
|
*/ |
87
|
|
|
public function setIcon(string $icon) |
88
|
|
|
{ |
89
|
|
|
$this->icon = $icon; |
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @return string |
95
|
|
|
*/ |
96
|
|
|
public function getText(): string |
97
|
|
|
{ |
98
|
|
|
return $this->text; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @param string $text |
103
|
|
|
* @return SlackMessage |
104
|
|
|
*/ |
105
|
|
|
public function setText(string $text) |
106
|
|
|
{ |
107
|
|
|
$this->text = $this->escapeCharacters($text); |
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return int |
113
|
|
|
*/ |
114
|
|
|
public function getQuoteType(): int |
115
|
|
|
{ |
116
|
|
|
return $this->quoteType; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param int $quoteType |
121
|
|
|
* @return SlackMessage |
122
|
|
|
*/ |
123
|
|
|
public function setQuoteType(int $quoteType) |
124
|
|
|
{ |
125
|
|
|
$this->quoteType = $quoteType; |
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return string |
131
|
|
|
*/ |
132
|
|
|
public function getQuoteTitle(): string |
133
|
|
|
{ |
134
|
|
|
return $this->quoteTitle; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @param string $quoteTitle |
139
|
|
|
* @return SlackMessage |
140
|
|
|
*/ |
141
|
|
|
public function setQuoteTitle(string $quoteTitle) |
142
|
|
|
{ |
143
|
|
|
$this->quoteTitle = $this->escapeCharacters($quoteTitle); |
144
|
|
|
return $this; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return string |
149
|
|
|
*/ |
150
|
|
|
public function getQuoteTitleLink(): string |
151
|
|
|
{ |
152
|
|
|
return $this->quoteTitleLink; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param string $quoteTitleLink |
157
|
|
|
* @return SlackMessage |
158
|
|
|
*/ |
159
|
|
|
public function setQuoteTitleLink(string $quoteTitleLink) |
160
|
|
|
{ |
161
|
|
|
$this->quoteTitleLink = $this->escapeCharacters($quoteTitleLink); |
162
|
|
|
return $this; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @return string |
167
|
|
|
*/ |
168
|
|
|
public function getQuoteText(): string |
169
|
|
|
{ |
170
|
|
|
return $this->quoteText; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @param string $quoteText |
175
|
|
|
* @return SlackMessage |
176
|
|
|
*/ |
177
|
|
|
public function setQuoteText(string $quoteText) |
178
|
|
|
{ |
179
|
|
|
$this->quoteText = $this->escapeCharacters($quoteText); |
180
|
|
|
return $this; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @return bool |
185
|
|
|
*/ |
186
|
|
|
public function isShowQuote(): bool |
187
|
|
|
{ |
188
|
|
|
return $this->showQuote; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @param bool $showQuote |
193
|
|
|
* @return SlackMessage |
194
|
|
|
*/ |
195
|
|
|
public function setShowQuote(bool $showQuote) |
196
|
|
|
{ |
197
|
|
|
$this->showQuote = $showQuote; |
198
|
|
|
return $this; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return string |
203
|
|
|
*/ |
204
|
|
|
public function getRecipient(): string |
205
|
|
|
{ |
206
|
|
|
return $this->recipient; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @param string $recipient |
211
|
|
|
* @return SlackMessage |
212
|
|
|
*/ |
213
|
|
|
public function setRecipient(string $recipient) |
214
|
|
|
{ |
215
|
|
|
$this->recipient = $this->escapeCharacters($recipient); |
216
|
|
|
return $this; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @return string |
221
|
|
|
*/ |
222
|
|
|
public function getSender(): string |
223
|
|
|
{ |
224
|
|
|
return $this->sender; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* @param string $sender |
229
|
|
|
* @return SlackMessage |
230
|
|
|
*/ |
231
|
|
|
public function setSender(string $sender) |
232
|
|
|
{ |
233
|
|
|
$this->sender = $this->escapeCharacters($sender); |
234
|
|
|
return $this; |
235
|
|
|
} |
236
|
|
|
} |
237
|
|
|
|