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