1
|
|
|
<?php |
2
|
|
|
namespace Maknz\Slack\Object; |
3
|
|
|
|
4
|
|
|
use InvalidArgumentException; |
5
|
|
|
use Maknz\Slack\BlockElement\Text; |
6
|
|
|
|
7
|
|
|
class Confirmation extends CompositionObject |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Confirmation title. |
11
|
|
|
* |
12
|
|
|
* @var Maknz\Slack\BlockElement\Text |
|
|
|
|
13
|
|
|
*/ |
14
|
|
|
protected $title; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Confirmation explanatory text. |
18
|
|
|
* |
19
|
|
|
* @var Maknz\Slack\BlockElement\Text |
20
|
|
|
*/ |
21
|
|
|
protected $text; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Text that confirms the action. |
25
|
|
|
* |
26
|
|
|
* @var Maknz\Slack\BlockElement\Text |
27
|
|
|
*/ |
28
|
|
|
protected $confirm; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Text that denies the action. |
32
|
|
|
* |
33
|
|
|
* @var Maknz\Slack\BlockElement\Text |
34
|
|
|
*/ |
35
|
|
|
protected $deny; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Internal attribute to property map. |
39
|
|
|
* |
40
|
|
|
* @var array |
41
|
|
|
*/ |
42
|
|
|
protected static $availableAttributes = [ |
43
|
|
|
'title' => 'title', |
44
|
|
|
'text' => 'text', |
45
|
|
|
'confirm' => 'confirm', |
46
|
|
|
'deny' => 'deny', |
47
|
|
|
]; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Get the confirmation title. |
51
|
|
|
* |
52
|
|
|
* @return Maknz\Slack\BlockElement\Text |
53
|
|
|
*/ |
54
|
9 |
|
public function getTitle() |
55
|
|
|
{ |
56
|
9 |
|
return $this->title; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Set the confirmation title. |
61
|
|
|
* |
62
|
|
|
* @param mixed $title |
63
|
|
|
* |
64
|
|
|
* @return Confirmation |
65
|
|
|
* |
66
|
|
|
* @throws \InvalidArgumentException |
67
|
|
|
*/ |
68
|
9 |
|
public function setTitle($title) |
69
|
|
|
{ |
70
|
9 |
|
$this->title = Text::create($title, Text::TYPE_PLAIN); |
|
|
|
|
71
|
|
|
|
72
|
9 |
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Get the confirmation explanatory text. |
77
|
|
|
* |
78
|
|
|
* @return Maknz\Slack\BlockElement\Text |
79
|
|
|
*/ |
80
|
9 |
|
public function getText() |
81
|
|
|
{ |
82
|
9 |
|
return $this->text; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Set the confirmation explanatory text. |
87
|
|
|
* |
88
|
|
|
* @param mixed $text |
89
|
|
|
* |
90
|
|
|
* @return Confirmation |
91
|
|
|
* |
92
|
|
|
* @throws \InvalidArgumentException |
93
|
|
|
*/ |
94
|
9 |
|
public function setText($text) |
95
|
|
|
{ |
96
|
9 |
|
$this->text = Text::create($text); |
|
|
|
|
97
|
|
|
|
98
|
9 |
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Get the text that confirms the action. |
103
|
|
|
* |
104
|
|
|
* @return Maknz\Slack\BlockElement\Text |
105
|
|
|
*/ |
106
|
9 |
|
public function getConfirm() |
107
|
|
|
{ |
108
|
9 |
|
return $this->confirm; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Set the text that confirms the action. |
113
|
|
|
* |
114
|
|
|
* @param mixed $confirm |
115
|
|
|
* |
116
|
|
|
* @return Confirmation |
117
|
|
|
* |
118
|
|
|
* @throws \InvalidArgumentException |
119
|
|
|
*/ |
120
|
9 |
|
public function setConfirm($confirm) |
121
|
|
|
{ |
122
|
9 |
|
$this->confirm = Text::create($confirm, Text::TYPE_PLAIN); |
|
|
|
|
123
|
|
|
|
124
|
9 |
|
return $this; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Get the text that denies the action. |
129
|
|
|
* |
130
|
|
|
* @return Maknz\Slack\BlockElement\Text |
131
|
|
|
*/ |
132
|
9 |
|
public function getDeny() |
133
|
|
|
{ |
134
|
9 |
|
return $this->deny; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Set the text that denies the action. |
139
|
|
|
* |
140
|
|
|
* @param mixed $deny |
141
|
|
|
* |
142
|
|
|
* @return Confirmation |
143
|
|
|
* |
144
|
|
|
* @throws \InvalidArgumentException |
145
|
|
|
*/ |
146
|
9 |
|
public function setDeny($deny) |
147
|
|
|
{ |
148
|
9 |
|
$this->deny = Text::Create($deny, Text::TYPE_PLAIN); |
|
|
|
|
149
|
|
|
|
150
|
9 |
|
return $this; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Convert the block to its array representation. |
155
|
|
|
* |
156
|
|
|
* @return array |
157
|
|
|
*/ |
158
|
9 |
|
public function toArray() |
159
|
|
|
{ |
160
|
|
|
$data = [ |
161
|
9 |
|
'title' => $this->getTitle()->toArray(), |
162
|
9 |
|
'text' => $this->getText()->toArray(), |
163
|
9 |
|
'confirm' => $this->getConfirm()->toArray(), |
164
|
9 |
|
'deny' => $this->getDeny()->toArray(), |
165
|
|
|
]; |
166
|
|
|
|
167
|
9 |
|
return $data; |
168
|
|
|
} |
169
|
|
|
} |
170
|
|
|
|