InputBlock   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
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 32
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 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\Block;
14
15
use App\Slack\MessageBuilder\Element\InputBlockElementInterface;
16
use App\Slack\MessageBuilder\Element\PlainTextElement;
17
use App\Slack\MessageBuilder\Enum\MessageTypeEnum;
18
use App\Slack\MessageBuilder\MessageJsonSerializeTrait;
19
20
class InputBlock implements BlockInterface
21
{
22
    use MessageJsonSerializeTrait;
23
24
    /** @var string */
25
    private $type;
26
    /** @var PlainTextElement */
27
    private $label;
28
    /** @var InputBlockElementInterface */
29
    private $element;
30
    /** @var bool */
31
    private $optional;
32
    /** @var PlainTextElement|null */
33
    private $hint;
34
35
    public function __construct(string $label, InputBlockElementInterface $element, bool $optional = false, string $hint = '')
36
    {
37
        if (\strlen($label) > 2000) {
38
            throw new \InvalidArgumentException('$label too long!');
39
        }
40
        if (\strlen($hint) > 2000) {
41
            throw new \InvalidArgumentException('$hint too long!');
42
        }
43
        $this->type = MessageTypeEnum::BLOCK_INPUT;
44
        $this->label = new PlainTextElement($label);
45
        $this->element = $element;
46
        $this->optional = $optional;
47
        if ('' !== $hint) {
48
            $this->hint = new PlainTextElement($hint);
49
        }
50
    }
51
}
52