OverflowMenuElement   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 34
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 4
1
<?php
2
3
/** @noinspection 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 OverflowMenuElement implements SectionBlockElementInterface, ActionsBlockElementInterface
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 ConfirmationDialogObject */
31
    private $confirmDialog;
32
    /** @var array|OptionObject[] */
33
    private $options;
34
35
    public function __construct(string $placeholder, string $actionId, ConfirmationDialogObject $confirmDialog = null, OptionObject ...$options)
36
    {
37
        if (\strlen($actionId) > 255) {
38
            throw new \InvalidArgumentException('$actionId too long!');
39
        }
40
        if (\count($options) > 5) {
41
            throw new \InvalidArgumentException('$options too long!');
42
        }
43
        if (\count($options) < 2) {
44
            throw new \InvalidArgumentException('$options too short!');
45
        }
46
47
        $this->type = MessageTypeEnum::ELEMENT_OVERFLOW_MENU;
48
        $this->placeholder = new PlainTextElement($placeholder);
49
        $this->actionId = $actionId;
50
        $this->confirmDialog = $confirmDialog;
51
        $this->options = $options;
52
    }
53
}
54