Passed
Push — master ( c66683...8a61e6 )
by Alexander
05:02
created

Confirmation::setTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Maknz\Slack\CompositionObject;
3
4
use Maknz\Slack\BlockElement\Text;
5
6
class Confirmation extends CompositionObject
7
{
8
    /**
9
     * Confirmation title.
10
     *
11
     * @var \Maknz\Slack\BlockElement\Text
12
     */
13
    protected $title;
14
15
    /**
16
     * Confirmation explanatory text.
17
     *
18
     * @var \Maknz\Slack\BlockElement\Text
19
     */
20
    protected $text;
21
22
    /**
23
     * Text that confirms the action.
24
     *
25
     * @var \Maknz\Slack\BlockElement\Text
26
     */
27
    protected $confirm;
28
29
    /**
30
     * Text that denies the action.
31
     *
32
     * @var \Maknz\Slack\BlockElement\Text
33
     */
34
    protected $deny;
35
36
    /**
37
     * Internal attribute to property map.
38
     *
39
     * @var array
40
     */
41
    protected static $availableAttributes = [
42
        'title'   => 'title',
43
        'text'    => 'text',
44
        'confirm' => 'confirm',
45
        'deny'    => 'deny',
46
    ];
47
48
    /**
49
     * Get the confirmation title.
50
     *
51
     * @return \Maknz\Slack\BlockElement\Text
52
     */
53 18
    public function getTitle()
54
    {
55 18
        return $this->title;
56
    }
57
58
    /**
59
     * Set the confirmation title.
60
     *
61
     * @param mixed $title
62
     *
63
     * @return $this
64
     *
65
     * @throws \InvalidArgumentException
66
     */
67 18
    public function setTitle($title)
68
    {
69 18
        $this->title = Text::create($title, Text::TYPE_PLAIN);
70
71 18
        return $this;
72
    }
73
74
    /**
75
     * Get the confirmation explanatory text.
76
     *
77
     * @return \Maknz\Slack\BlockElement\Text
78
     */
79 18
    public function getText()
80
    {
81 18
        return $this->text;
82
    }
83
84
    /**
85
     * Set the confirmation explanatory text.
86
     *
87
     * @param mixed $text
88
     *
89
     * @return $this
90
     *
91
     * @throws \InvalidArgumentException
92
     */
93 18
    public function setText($text)
94
    {
95 18
        $this->text = Text::create($text);
96
97 18
        return $this;
98
    }
99
100
    /**
101
     * Get the text that confirms the action.
102
     *
103
     * @return \Maknz\Slack\BlockElement\Text
104
     */
105 18
    public function getConfirm()
106
    {
107 18
        return $this->confirm;
108
    }
109
110
    /**
111
     * Set the text that confirms the action.
112
     *
113
     * @param mixed $confirm
114
     *
115
     * @return $this
116
     *
117
     * @throws \InvalidArgumentException
118
     */
119 18
    public function setConfirm($confirm)
120
    {
121 18
        $this->confirm = Text::create($confirm, Text::TYPE_PLAIN);
122
123 18
        return $this;
124
    }
125
126
    /**
127
     * Get the text that denies the action.
128
     *
129
     * @return \Maknz\Slack\BlockElement\Text
130
     */
131 18
    public function getDeny()
132
    {
133 18
        return $this->deny;
134
    }
135
136
    /**
137
     * Set the text that denies the action.
138
     *
139
     * @param mixed $deny
140
     *
141
     * @return $this
142
     *
143
     * @throws \InvalidArgumentException
144
     */
145 18
    public function setDeny($deny)
146
    {
147 18
        $this->deny = Text::Create($deny, Text::TYPE_PLAIN);
148
149 18
        return $this;
150
    }
151
152
    /**
153
     * Convert the block to its array representation.
154
     *
155
     * @return array
156
     */
157 18
    public function toArray()
158
    {
159 18
        $data = [
160 18
            'title'   => $this->getTitle()->toArray(),
161 18
            'text'    => $this->getText()->toArray(),
162 18
            'confirm' => $this->getConfirm()->toArray(),
163 18
            'deny'    => $this->getDeny()->toArray(),
164
        ];
165
166 18
        return $data;
167
    }
168
}
169