1 | <?php |
||
11 | class RocketChatAttachment |
||
12 | { |
||
13 | /** |
||
14 | * @var string The color you want the order on the left side to be, any value background-css supports. |
||
15 | */ |
||
16 | protected $color = ''; |
||
17 | |||
18 | /** |
||
19 | * @var string The text to display for this attachment, it is different than the message’s text. |
||
20 | */ |
||
21 | protected $text = ''; |
||
22 | /** |
||
23 | * @var string Displays the time next to the text portion. |
||
24 | */ |
||
25 | protected $timestamp = ''; |
||
26 | /** |
||
27 | * @var string An image that displays to the left of the text, looks better when this is relatively small. |
||
28 | */ |
||
29 | protected $thumbnailUrl = ''; |
||
30 | /** |
||
31 | * @var string Only applicable if the ts is provided, as it makes the time clickable to this link. |
||
32 | */ |
||
33 | protected $messageLink = ''; |
||
34 | /** |
||
35 | * @var bool Causes the image, audio, and video sections to be hiding when collapsed is true. |
||
36 | */ |
||
37 | protected $collapsed = false; |
||
38 | /** |
||
39 | * @var string Name of the author. |
||
40 | */ |
||
41 | protected $authorName = ''; |
||
42 | /** |
||
43 | * @var string Providing this makes the author name clickable and points to this link. |
||
44 | */ |
||
45 | protected $authorLink = ''; |
||
46 | /** |
||
47 | * @var string Displays a tiny icon to the left of the Author’s name. |
||
48 | */ |
||
49 | protected $authorIcon = ''; |
||
50 | /** |
||
51 | * @var string Title to display for this attachment, displays under the author. |
||
52 | */ |
||
53 | protected $title = ''; |
||
54 | /** |
||
55 | * @var string Providing this makes the title clickable, pointing to this link. |
||
56 | */ |
||
57 | protected $titleLink = ''; |
||
58 | /** |
||
59 | * @var bool When this is true, a download icon appears and clicking this saves the link to file. |
||
60 | */ |
||
61 | protected $titleLinkDownload = false; |
||
62 | /** |
||
63 | * @var string The image to display, will be “big” and easy to see. |
||
64 | */ |
||
65 | protected $imageUrl = ''; |
||
66 | /** |
||
67 | * @var string Audio file to play, only supports what html audio does. |
||
68 | */ |
||
69 | protected $audioUrl = ''; |
||
70 | /** |
||
71 | * @var string Video file to play, only supports what html video does. |
||
72 | */ |
||
73 | protected $videoUrl = ''; |
||
74 | /** |
||
75 | * @var array An array of Attachment Field Objects. |
||
76 | */ |
||
77 | protected $fields = []; |
||
78 | |||
79 | /** |
||
80 | * RocketChatAttachment constructor. |
||
81 | * @param array|null $config |
||
82 | */ |
||
83 | 26 | public function __construct(array $config = null) |
|
89 | |||
90 | /** |
||
91 | * Create a new instance of RocketChatAttachment. |
||
92 | * |
||
93 | * @param array|null $config |
||
94 | * @return RocketChatAttachment |
||
95 | */ |
||
96 | 4 | public static function create(array $config = null) |
|
100 | |||
101 | /** |
||
102 | * set attachment data form array. |
||
103 | * |
||
104 | * @param array $data |
||
105 | */ |
||
106 | 5 | protected function setFromArray(array $data) |
|
116 | |||
117 | /** |
||
118 | * @param string $color |
||
119 | * @return RocketChatAttachment |
||
120 | */ |
||
121 | 1 | public function color(string $color): self |
|
127 | |||
128 | /** |
||
129 | * @param string $text |
||
130 | * @return RocketChatAttachment |
||
131 | */ |
||
132 | 1 | public function text(string $text): self |
|
138 | |||
139 | /** |
||
140 | * @param string|\DateTime $timestamp |
||
141 | * @return RocketChatAttachment |
||
142 | */ |
||
143 | 2 | public function timestamp($timestamp): self |
|
157 | |||
158 | /** |
||
159 | * @param string $thumbnailUrl |
||
160 | * @return RocketChatAttachment |
||
161 | */ |
||
162 | 1 | public function thumbnailUrl(string $thumbnailUrl): self |
|
168 | |||
169 | /** |
||
170 | * @param string $messageLink |
||
171 | * @return RocketChatAttachment |
||
172 | */ |
||
173 | 1 | public function messageLink(string $messageLink): self |
|
179 | |||
180 | /** |
||
181 | * @param bool $collapsed |
||
182 | * @return RocketChatAttachment |
||
183 | */ |
||
184 | 1 | public function collapsed(bool $collapsed): self |
|
190 | |||
191 | /** |
||
192 | * @param string $name |
||
193 | * @param string $link |
||
194 | * @param string $icon |
||
195 | * @return RocketChatAttachment |
||
196 | */ |
||
197 | 1 | public function author(string $name, string $link = '', string $icon = ''): self |
|
205 | |||
206 | /** |
||
207 | * @param string $authorName |
||
208 | * @return RocketChatAttachment |
||
209 | */ |
||
210 | 2 | public function authorName(string $authorName): self |
|
216 | |||
217 | /** |
||
218 | * @param string $authorLink |
||
219 | * @return RocketChatAttachment |
||
220 | */ |
||
221 | 2 | public function authorLink(string $authorLink): self |
|
227 | |||
228 | /** |
||
229 | * @param string $authorIcon |
||
230 | * @return RocketChatAttachment |
||
231 | */ |
||
232 | 2 | public function authorIcon(string $authorIcon): self |
|
238 | |||
239 | /** |
||
240 | * @param string $title |
||
241 | * @return RocketChatAttachment |
||
242 | */ |
||
243 | 5 | public function title(string $title): self |
|
249 | |||
250 | /** |
||
251 | * @param string $titleLink |
||
252 | * @return RocketChatAttachment |
||
253 | */ |
||
254 | 1 | public function titleLink(string $titleLink): self |
|
260 | |||
261 | /** |
||
262 | * @param bool $titleLinkDownload |
||
263 | * @return RocketChatAttachment |
||
264 | */ |
||
265 | 1 | public function titleLinkDownload(bool $titleLinkDownload): self |
|
271 | |||
272 | /** |
||
273 | * @param string $imageUrl |
||
274 | * @return RocketChatAttachment |
||
275 | */ |
||
276 | 1 | public function imageUrl(string $imageUrl): self |
|
282 | |||
283 | /** |
||
284 | * @param string $audioUrl |
||
285 | * @return RocketChatAttachment |
||
286 | */ |
||
287 | 1 | public function audioUrl(string $audioUrl): self |
|
293 | |||
294 | /** |
||
295 | * @param string $videoUrl |
||
296 | * @return RocketChatAttachment |
||
297 | */ |
||
298 | 1 | public function videoUrl(string $videoUrl): self |
|
304 | |||
305 | /** |
||
306 | * @param array $fields |
||
307 | * @return RocketChatAttachment |
||
308 | */ |
||
309 | 1 | public function fields(array $fields): self |
|
315 | |||
316 | /** |
||
317 | * Get an array representation of the RocketChatAttachment. |
||
318 | * |
||
319 | * @return array |
||
320 | */ |
||
321 | 22 | public function toArray(): array |
|
344 | } |
||
345 |