|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** @noinspection DuplicatedCode, UnusedConstructorDependenciesInspection */ |
|
4
|
|
|
|
|
5
|
|
|
declare(strict_types=1); |
|
6
|
|
|
|
|
7
|
|
|
/* |
|
8
|
|
|
* This file is part of the zibios/sharep. |
|
9
|
|
|
* |
|
10
|
|
|
* (c) Zbigniew Ślązak |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace App\Slack\MessageBuilder\Element; |
|
14
|
|
|
|
|
15
|
|
|
use App\Slack\MessageBuilder\Enum\MessageTypeEnum; |
|
16
|
|
|
use App\Slack\MessageBuilder\MessageJsonSerializeTrait; |
|
17
|
|
|
use App\Slack\MessageBuilder\Object\ConfirmationDialogObject; |
|
18
|
|
|
use App\Slack\MessageBuilder\Object\OptionGroupObject; |
|
19
|
|
|
use App\Slack\MessageBuilder\Object\OptionObject; |
|
20
|
|
|
|
|
21
|
|
|
class SelectStaticGroupElement implements SectionBlockElementInterface, ActionsBlockElementInterface, InputBlockElementInterface |
|
22
|
|
|
{ |
|
23
|
|
|
use MessageJsonSerializeTrait; |
|
24
|
|
|
|
|
25
|
|
|
/** @var string */ |
|
26
|
|
|
private $type; |
|
27
|
|
|
/** @var PlainTextElement */ |
|
28
|
|
|
private $placeholder; |
|
29
|
|
|
/** @var string */ |
|
30
|
|
|
private $actionId; |
|
31
|
|
|
/** @var OptionObject */ |
|
32
|
|
|
private $initialOption; |
|
33
|
|
|
/** @var ConfirmationDialogObject */ |
|
34
|
|
|
private $confirmDialog; |
|
35
|
|
|
/** @var array|OptionGroupObject[] */ |
|
36
|
|
|
private $optionGroups; |
|
37
|
|
|
|
|
38
|
|
|
public function __construct(string $placeholder, string $actionId, OptionObject $initialOption = null, ConfirmationDialogObject $confirmDialog = null, OptionGroupObject ...$optionGroups) |
|
39
|
|
|
{ |
|
40
|
|
|
if (\strlen($placeholder) > 150) { |
|
41
|
|
|
throw new \InvalidArgumentException('$text too long!'); |
|
42
|
|
|
} |
|
43
|
|
|
if (\strlen($actionId) > 255) { |
|
44
|
|
|
throw new \InvalidArgumentException('$actionId too long!'); |
|
45
|
|
|
} |
|
46
|
|
|
if (\count($optionGroups) > 100) { |
|
47
|
|
|
throw new \InvalidArgumentException('$options too long!'); |
|
48
|
|
|
} |
|
49
|
|
|
if (0 === \count($optionGroups)) { |
|
50
|
|
|
throw new \InvalidArgumentException('$url too short!'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$this->type = MessageTypeEnum::ELEMENT_SELECT_STATIC; |
|
54
|
|
|
$this->placeholder = new PlainTextElement($placeholder); |
|
55
|
|
|
$this->actionId = $actionId; |
|
56
|
|
|
$this->initialOption = $initialOption; |
|
57
|
|
|
$this->confirmDialog = $confirmDialog; |
|
58
|
|
|
$this->optionGroups = $optionGroups; |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|