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

DatePickerElement::__construct()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 0
cts 12
cp 0
rs 9.7
c 0
b 0
f 0
cc 4
nc 4
nop 4
crap 20
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
19
class DatePickerElement implements
20
    SectionBlockElementInterface,
21
    ActionsBlockElementInterface,
22
    InputBlockElementInterface
23
{
24
    use MessageJsonSerializeTrait;
25
26
    /** @var string */
27
    private $type;
28
    /** @var string */
29
    private $actionId;
30
    /** @var PlainTextElement */
31
    private $placeholder;
32
    /** @var string */
33
    private $initialDate;
34
    /** @var ConfirmationDialogObject */
35
    private $confirmDialog;
36
37
    public function __construct(string $actionId, string $placeholder = '', string $initialDate = '', ConfirmationDialogObject $confirmDialog = null)
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_DATE_PICKER;
47
        $this->actionId = $actionId;
48
        if ('' !== $placeholder) {
49
            $this->placeholder = new PlainTextElement($placeholder);
50
        }
51
        $this->initialDate = $initialDate;
52
        $this->confirmDialog = $confirmDialog;
53
    }
54
}
55