1 | <?php |
||
7 | class AttachmentAction |
||
8 | { |
||
9 | const STYLE_DEFAULT = 'default'; |
||
10 | const STYLE_PRIMARY = 'primary'; |
||
11 | const STYLE_DANGER = 'danger'; |
||
12 | |||
13 | /** |
||
14 | * The required name field of the action. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $name; |
||
19 | |||
20 | /** |
||
21 | * The required text field of the action. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $text; |
||
26 | |||
27 | /** |
||
28 | * The required type field of the action. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $type; |
||
33 | |||
34 | /** |
||
35 | * The value of the action. |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $value = ''; |
||
40 | |||
41 | /** |
||
42 | * The style of the action. |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $style = self::STYLE_DEFAULT; |
||
47 | |||
48 | /** |
||
49 | * An optional confirmation |
||
50 | * dialog for the action |
||
51 | * |
||
52 | * @var null|array |
||
53 | */ |
||
54 | protected $confirmation = null; |
||
55 | |||
56 | public static function create($name, $text, $type) |
||
60 | |||
61 | public function __construct(string $name, string $text, string $type) |
||
67 | |||
68 | /** |
||
69 | * Set the name of the action. |
||
70 | * |
||
71 | * @param string $name |
||
72 | * |
||
73 | * @return AttachmentAction |
||
74 | */ |
||
75 | public function setName(string $name): AttachmentAction |
||
81 | |||
82 | /** |
||
83 | * Set the text of the action. |
||
84 | * |
||
85 | * @param string $text |
||
86 | * |
||
87 | * @return AttachmentAction |
||
88 | */ |
||
89 | public function setText(string $text): AttachmentAction |
||
95 | |||
96 | /** |
||
97 | * Set the type of the action. |
||
98 | * |
||
99 | * @param string $type |
||
100 | * |
||
101 | * @return AttachmentAction |
||
102 | */ |
||
103 | public function setType(string $type): AttachmentAction |
||
109 | |||
110 | /** |
||
111 | * Set the value of the action. |
||
112 | * |
||
113 | * @param string $value |
||
114 | * |
||
115 | * @return AttachmentAction |
||
116 | */ |
||
117 | public function setValue(string $value): AttachmentAction |
||
123 | |||
124 | /** |
||
125 | * Set the style of the action. |
||
126 | * |
||
127 | * @param string $style |
||
128 | * |
||
129 | * @return AttachmentAction |
||
130 | */ |
||
131 | public function setStyle(string $style): AttachmentAction |
||
137 | |||
138 | /** |
||
139 | * Sets the confirmation hash for the action. |
||
140 | * |
||
141 | * @param array $confirmation |
||
142 | * |
||
143 | * @return \Spatie\SlashCommand\AttachmentAction |
||
144 | * @throws \Spatie\SlashCommand\Exceptions\InvalidConfirmationHash |
||
145 | */ |
||
146 | public function setConfirmation(array $confirmation) |
||
156 | |||
157 | /** |
||
158 | * Convert this action to its array representation. |
||
159 | * |
||
160 | * @return array |
||
161 | */ |
||
162 | public function toArray(): array |
||
173 | } |
||
174 |