1 | <?php |
||
11 | class MessageBuilder |
||
12 | { |
||
13 | /** |
||
14 | * @var ApiClient An API client. |
||
15 | */ |
||
16 | private $client; |
||
17 | |||
18 | /** |
||
19 | * @var array An array of data to pass to the built message. |
||
20 | */ |
||
21 | protected $data = []; |
||
22 | |||
23 | /** |
||
24 | * Creates a new message builder. |
||
25 | * |
||
26 | * @param ApiClient $client The API client the builder is working for. |
||
27 | */ |
||
28 | 5 | public function __construct(ApiClient $client) |
|
32 | |||
33 | /** |
||
34 | * Creates and returns a new message object specified by the builder. |
||
35 | * |
||
36 | * @return Message A new message object. |
||
37 | */ |
||
38 | 5 | public function create() |
|
42 | |||
43 | /** |
||
44 | * Sets the message text. |
||
45 | * |
||
46 | * @param string $text The message body text. |
||
47 | * @param bool $markdown Enable or disable Markdown parsing of the text. |
||
48 | * @return $this |
||
49 | */ |
||
50 | 1 | public function setText($text, $markdown = true) |
|
56 | |||
57 | /** |
||
58 | * Sets the channel the message should be posted to. |
||
59 | * |
||
60 | * @param ChannelInterface $channel A channel to post to. |
||
61 | * @return $this |
||
62 | */ |
||
63 | 1 | public function setChannel(ChannelInterface $channel) |
|
68 | |||
69 | /** |
||
70 | * Sets the user the message is sent from. |
||
71 | * |
||
72 | * @param User $user A user. |
||
73 | * @return $this |
||
74 | */ |
||
75 | 1 | public function setUser(User $user) |
|
80 | |||
81 | /** |
||
82 | * Adds an attachment to the message. |
||
83 | * |
||
84 | * @param Attachment $attachment The attachment to add. |
||
85 | * @return $this |
||
86 | */ |
||
87 | 1 | public function addAttachment(Attachment $attachment) |
|
92 | } |
||
93 |