Failed Conditions
Push — master ( 37c7e1...8f957f )
by Zbigniew
05:34
created

DatePickerElement   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 33
ccs 9
cts 12
cp 0.75
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 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 1
    public function __construct(string $actionId, string $placeholder = '', string $initialDate = '', ConfirmationDialogObject $confirmDialog = null)
35
    {
36 1
        if (\strlen($actionId) > 255) {
37
            throw new \InvalidArgumentException('$actionId too long!');
38
        }
39 1
        if (\strlen($placeholder) > 150) {
40
            throw new \InvalidArgumentException('$placeholder too long!');
41
        }
42
43 1
        $this->type = MessageTypeEnum::ELEMENT_DATE_PICKER;
44 1
        $this->actionId = $actionId;
45 1
        if ('' !== $placeholder) {
46
            $this->placeholder = new PlainTextElement($placeholder);
47
        }
48 1
        $this->initialDate = $initialDate;
49 1
        $this->confirmDialog = $confirmDialog;
50 1
    }
51
}
52