Failed Conditions
Push — master ( eac8ff...e4a057 )
by Zbigniew
04:46
created

RadioButtonGroupElement   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 31
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 3
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 RadioButtonGroupElement implements SectionBlockElementInterface, ActionsBlockElementInterface, InputBlockElementInterface
21
{
22
    use MessageJsonSerializeTrait;
23
24
    /** @var string */
25
    private $type;
26
    /** @var string */
27
    private $actionId;
28
    /** @var ConfirmationDialogObject|null */
29
    private $confirmDialog;
30
    /** @var OptionObject|null */
31
    private $initialOption;
32
    /** @var array|OptionObject[] */
33
    private $options;
34
35
    public function __construct(string $actionId, ConfirmationDialogObject $confirmDialog = null, OptionObject $initialOption = null, OptionObject ...$options)
36
    {
37
        if (\strlen($actionId) > 255) {
38
            throw new \InvalidArgumentException('$actionId too long!');
39
        }
40
        if (\count($options) < 1) {
41
            throw new \InvalidArgumentException('$options too short!');
42
        }
43
44
        $this->type = MessageTypeEnum::ELEMENT_RADIO_BUTTONS;
45
        $this->actionId = $actionId;
46
        $this->confirmDialog = $confirmDialog;
47
        $this->initialOption = $initialOption;
48
        $this->options = $options;
49
    }
50
}
51