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

DatePickerElement   A

Complexity

Total Complexity 4

Size/Duplication

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 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\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