PlainTextInputElement::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 0
cts 13
cp 0
rs 9.7
c 0
b 0
f 0
cc 3
nc 3
nop 6
crap 12
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
18
class PlainTextInputElement implements SectionBlockElementInterface
19
{
20
    use MessageJsonSerializeTrait;
21
22
    /** @var string */
23
    private $type;
24
    /** @var string */
25
    private $actionId;
26
    /** @var PlainTextElement */
27
    private $placeholder;
28
    /** @var string */
29
    private $initialValue;
30
    /** @var bool */
31
    private $multiline;
32
    /** @var int */
33
    private $minLength;
34
    /** @var int */
35
    private $maxLength;
36
37
    public function __construct(string $actionId, string $placeholder = '', string $initialValue = '', bool $multiline = false, int $minLength = 1, int $maxLength = 3000)
38
    {
39
        if (\strlen($actionId) > 255) {
40
            throw new \InvalidArgumentException('$actionId too long!');
41
        }
42
        if (\strlen($placeholder) > 150) {
43
            throw new \InvalidArgumentException('$placeholder too long!');
44
        }
45
46
        $this->type = MessageTypeEnum::ELEMENT_INPUT_PLAIN_TEXT;
47
        $this->actionId = $actionId;
48
        $this->placeholder = new PlainTextElement($placeholder);
49
        $this->initialValue = $initialValue;
50
        $this->multiline = $multiline;
51
        $this->minLength = $minLength;
52
        $this->maxLength = $maxLength;
53
    }
54
}
55