Confirmable::getActionId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
namespace Maknz\Slack\BlockElement;
3
4
use InvalidArgumentException;
5
use Maknz\Slack\BlockElement;
6
use Maknz\Slack\CompositionObject\Confirmation;
7
8
abstract class Confirmable extends BlockElement
9
{
10
    /**
11
     * Action triggered when the element is interacted with.
12
     *
13
     * @var string
14
     */
15
    protected $action_id;
16
17
    /**
18
     * Confirmation object.
19
     *
20
     * @var \Maknz\Slack\CompositionObject\Confirmation
21
     */
22
    protected $confirm;
23
24
    /**
25
     * Get the element's action identifier.
26
     *
27
     * @return string
28
     */
29 33
    public function getActionId()
30
    {
31 33
        return $this->action_id;
32
    }
33
34
    /**
35
     * Set the element's action identifier.
36
     *
37
     * @param string $actionId
38
     *
39
     * @return $this
40
     */
41 62
    public function setActionId($actionId)
42
    {
43 62
        $this->action_id = $actionId;
44
45 62
        return $this;
46
    }
47
48
    /**
49
     * Get the confirmation object.
50
     *
51
     * @return \Maknz\Slack\CompositionObject\Confirmation
52
     */
53 33
    public function getConfirm()
54
    {
55 33
        return $this->confirm;
56
    }
57
58
    /**
59
     * Set the confirmation object.
60
     *
61
     * @param mixed $confirm
62
     *
63
     * @return $this
64
     *
65
     * @throws \InvalidArgumentException
66
     */
67 19
    public function setConfirm($confirm)
68
    {
69 19
        if (is_array($confirm)) {
70 18
            $confirm = new Confirmation($confirm);
71
        }
72
73 19
        if ($confirm instanceof Confirmation) {
74 18
            $this->confirm = $confirm;
75
76 18
            return $this;
77
        }
78
79 1
        throw new InvalidArgumentException('Confirm must be a keyed array or '.Confirmation::class.' object');
80
    }
81
}
82