ActionConfirmation::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
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
 */
19
final class ActionConfirmation
20
{
21
    /**
22
     * The required title for the pop up window.
23
     *
24
     * @var string
25
     */
26
    private $title;
27
28
    /**
29
     * The required description.
30
     *
31
     * @var string
32
     */
33
    private $text;
34
35
    /**
36
     * The text label for the OK button.
37
     *
38
     * @var string|null
39
     */
40
    private $okText;
41
42
    /**
43
     * The text label for the Cancel button.
44
     *
45
     * @var string|null
46
     */
47
    private $dismissText;
48
49
    public function __construct(string $title, string $text)
50
    {
51
        $this->title = $title;
52
        $this->text = $text;
53
    }
54
55
    public function getTitle(): string
56
    {
57
        return $this->title;
58
    }
59
60
    public function getText(): string
61
    {
62
        return $this->text;
63
    }
64
65
    public function getOkText(): ?string
66
    {
67
        return $this->okText;
68
    }
69
70
    /**
71
     * @return ActionConfirmation
72
     */
73
    public function setOkText(?string $okText): self
74
    {
75
        $this->okText = $okText;
76
77
        return $this;
78
    }
79
80
    public function getDismissText(): ?string
81
    {
82
        return $this->dismissText;
83
    }
84
85
    /**
86
     * @return ActionConfirmation
87
     */
88
    public function setDismissText(?string $dismissText): self
89
    {
90
        $this->dismissText = $dismissText;
91
92
        return $this;
93
    }
94
95
    /**
96
     * Get the array representation of this action confirmation.
97
     */
98
    public function toArray(): array
99
    {
100
        return [
101
            'title' => $this->title,
102
            'text' => $this->text,
103
            'ok_text' => $this->okText,
104
            'dismiss_text' => $this->dismissText,
105
        ];
106
    }
107
}
108