1 <?php
2 namespace Slack\Message;
3
4 use Slack\DataObject;
5
6 /**
7 * A field inside a message attachment.
8 *
9 * @see https://api.slack.com/docs/attachments
10 */
11 class AttachmentField extends DataObject
12 {
13 /**
14 * Creates a new attachment field.
15 *
16 * @param string $title A text heading for the field.
17 * @param string $value The text value of the field.
18 * @param bool $short Indicates if the value can be displayed side-by-side with other values.
19 */
20 public function __construct($title, $value, $short = true)
21 {
22 $this->data['title'] = $title;
23 $this->data['value'] = $value;
24 $this->data['short'] = $short;
25 }
26
27 /**
28 * Gets the text heading for the field.
29 *
30 * @return string The text heading for the field.
31 */
32 public function getTitle()
33 {
34 return $this->data['title'];
35 }
36
37 /**
38 * Gets the text value of the field.
39 *
40 * @return string The text value of the field.
41 */
42 public function getValue()
43 {
44 return $this->data['value'];
45 }
46
47 /**
48 * Checks if the value can be displayed side-by-side with other values.
49 *
50 * @return bool True if the value is short, otherwise false.
51 */
52 public function isShort()
53 {
54 return isset($this->data['short']) && (bool)$this->data['short'];
55 }
56 }
57