1 <?php
2 namespace Slack\Message;
3
4 use Slack\ClientObject;
5
6 7 8
9 class Message extends ClientObject
10 {
11 12 13 14 15
16 public function getText()
17 {
18 return $this->data['text'];
19 }
20
21 22 23 24 25
26 public function isMarkdownEnabled()
27 {
28 return isset($this->data['mrkdwn']) ? $this->data['mrkdwn'] == true : true;
29 }
30
31 32 33 34 35
36 public function hasAttachments()
37 {
38 return isset($this->data['attachments']) && count($this->data['attachments']) > 0;
39 }
40
41 42 43 44 45
46 public function getAttachments()
47 {
48 return isset($this->data['attachments']) ? $this->data['attachments'] : [];
49 }
50
51 52 53 54 55
56 public function getChannel()
57 {
58 return $this->client->getChannelById($this->data['channel']);
59 }
60
61 62 63 64 65
66 public function getUser()
67 {
68 return $this->client->getUserById($this->data['user']);
69 }
70
71 72 73
74 public function jsonUnserialize(array $data)
75 {
76 if (!isset($this->data['attachments'])) {
77 return;
78 }
79
80 for ($i = 0; $i < count($this->data['attachments']); $i++) {
81 $this->data['attachments'][$i] = Attachment::fromData($this->data['attachments'][$i]);
82 }
83 }
84 }
85