MultiSelectStaticElement   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 45
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 27 5
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\OptionObject;
19
20
class MultiSelectStaticElement implements SectionBlockElementInterface, InputBlockElementInterface
21
{
22
    use MessageJsonSerializeTrait;
23
24
    /** @var string */
25
    private $type;
26
    /** @var PlainTextElement */
27
    private $placeholder;
28
    /** @var string */
29
    private $actionId;
30
    /** @var array|OptionObject[] */
31
    private $initialOptions;
32
    /** @var ConfirmationDialogObject */
33
    private $confirmDialog;
34
    /** @var array|OptionObject[] */
35
    private $options;
36
37
    public function __construct(
38
        string $placeholder,
39
        string $actionId,
40
        array $initialOptions = [],
41
        ConfirmationDialogObject $confirmDialog = null,
42
        OptionObject ...$options
43
    ) {
44
        if (\strlen($placeholder) > 150) {
45
            throw new \InvalidArgumentException('$text too long!');
46
        }
47
        if (\strlen($actionId) > 255) {
48
            throw new \InvalidArgumentException('$actionId too long!');
49
        }
50
        if (\count($options) > 100) {
51
            throw new \InvalidArgumentException('$options too long!');
52
        }
53
        if (0 === \count($options)) {
54
            throw new \InvalidArgumentException('$options too short!');
55
        }
56
57
        $this->type = MessageTypeEnum::ELEMENT_MULTI_SELECT_STATIC;
58
        $this->placeholder = new PlainTextElement($placeholder);
59
        $this->actionId = $actionId;
60
        $this->initialOptions = $initialOptions;
61
        $this->confirmDialog = $confirmDialog;
62
        $this->options = $options;
63
    }
64
}
65