Failed Conditions
Push — master ( 01c1f3...37c7e1 )
by Zbigniew
04:47
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 SectionBlockAccessoryInterface
20
{
21
    use MessageJsonSerializeTrait;
22
23
    /** @var string */
24
    private $type;
25
    /** @var string */
26
    private $actionId;
27
    /** @var PlainTextElement */
28
    private $placeholder;
29
    /** @var string */
30
    private $initialDate;
31
    /** @var ConfirmationDialogObject */
32
    private $confirmDialog;
33
34
    public function __construct(string $actionId, string $placeholder = '', string $initialDate = '', ConfirmationDialogObject $confirmDialog = null)
35
    {
36
        if (\strlen($actionId) > 255) {
37
            throw new \InvalidArgumentException('$actionId too long!');
38
        }
39
        if (\strlen($placeholder) > 150) {
40
            throw new \InvalidArgumentException('$placeholder too long!');
41
        }
42
43
        $this->type = MessageTypeEnum::ELEMENT_DATE_PICKER;
44
        $this->actionId = $actionId;
45
        if ('' !== $placeholder) {
46
            $this->placeholder = new PlainTextElement($placeholder);
47
        }
48
        $this->initialDate = $initialDate;
49
        $this->confirmDialog = $confirmDialog;
50
    }
51
}
52