Passed
Pull Request — master (#53)
by
unknown
01:19
created

DatePickerBlock   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 112
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
dl 0
loc 112
rs 10
c 1
b 0
f 0
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setActionId() 0 5 1
A setConfirm() 0 5 1
A setPlaceholder() 0 5 1
A setInitialDate() 0 5 1
A getInitialDate() 0 3 1
A getConfirm() 0 3 1
A toArray() 0 8 1
A getPlaceholder() 0 3 1
A getActionId() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Nexylan packages.
7
 *
8
 * (c) Nexylan SAS <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Nexy\Slack;
15
16
/**
17
 * @author Sullivan Senechal <[email protected]>
18
 * @author Mikey McLellan <[email protected]>
19
 */
20
final class DatePickerBlock extends Block
21
{
22
    /**
23
     * @var string
24
     */
25
    private $actionId;
26
27
    /**
28
     * @var string
29
     */
30
    private $initialDate;
31
32
    /**
33
     * @var TextBlock
34
     */
35
    private $placeholder;
36
37
    /**
38
     * @var ConfirmationDialogBlock
39
     */
40
    private $confirm;
41
42
    public function __construct()
43
    {
44
        parent::__construct('datepicker');
45
    }
46
47
    /**
48
     * @param string $actionId
49
     */
50
    public function setActionId(string $actionId): ButtonBlock
51
    {
52
        $this->actionId = $actionId;
53
54
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Nexy\Slack\DatePickerBlock which is incompatible with the type-hinted return Nexy\Slack\ButtonBlock.
Loading history...
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    public function getActionId(): string
61
    {
62
        return $this->actionId;
63
    }
64
65
    /**
66
     * @param string $initialDate
67
     */
68
    public function setInitialDate(string $initialDate): self
69
    {
70
        $this->initialDate = $initialDate;
71
72
        return $this;
73
    }
74
75
    /**
76
     * @return string
77
     */
78
    public function getInitialDate(): string
79
    {
80
        return $this->initialDate;
81
    }
82
83
    /**
84
     * @param ConfirmationDialogBlock $confirm
85
     */
86
    public function setConfirm(ConfirmationDialogBlock $confirm): self
87
    {
88
        $this->confirm = $confirm;
89
90
        return $this;
91
    }
92
93
    /**
94
     * @return ConfirmationDialogBlock
95
     */
96
    public function getConfirm(): ConfirmationDialogBlock
97
    {
98
        return $this->confirm;
99
    }
100
101
    /**
102
     * @return array
103
     */
104
    public function getPlaceholder(): TextBlock
105
    {
106
        return $this->placeholder;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->placeholder returns the type Nexy\Slack\TextBlock which is incompatible with the documented return type array.
Loading history...
107
    }
108
109
    /**
110
     * @param array $placeholder
111
     */
112
    public function setPlaceholder(TextBlock $placeholder): self
113
    {
114
        $this->placeholder = $placeholder;
115
116
        return $this;
117
    }
118
119
    /**
120
     * Convert this block to its array representation.
121
     *
122
     * @return array
123
     */
124
    public function toArray(): array
125
    {
126
        $data = [
127
            'image_url' => $this->imageUrl,
0 ignored issues
show
Bug Best Practice introduced by
The property imageUrl does not exist on Nexy\Slack\DatePickerBlock. Did you maybe forget to declare it?
Loading history...
128
            'alt_text' => $this->altText
0 ignored issues
show
Bug Best Practice introduced by
The property altText does not exist on Nexy\Slack\DatePickerBlock. Did you maybe forget to declare it?
Loading history...
129
        ];
130
131
        return array_merge(parent::toArray(), $this->removeNulls($data));
132
    }
133
}
134