Passed
Pull Request — master (#16)
by
unknown
02:10
created

ConfirmTemplate::addYesAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
eloc 1
nc 1
nop 3
1
<?php
2
3
/*
4
 * This file is part of the LineMob package.
5
 *
6
 * (c) Ishmael Doss <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LineMob\Core\Template;
13
14
use LINE\LINEBot\MessageBuilder\TemplateBuilder\ConfirmTemplateBuilder;
15
use LINE\LINEBot\MessageBuilder\TemplateMessageBuilder;
16
17
/**
18
 * @author YokYukYik <[email protected]>
19
 */
20
class ConfirmTemplate extends AbstractTemplate
21
{
22
    use ActionTemplateTrait;
23
24
    /**
25
     * @var string
26
     */
27
    public $altText = 'This is confirm template.';
28
29
    /**
30
     * @var string
31
     */
32
    public $title = 'Are You sure?';
33
34
    /**
35
     * @var Action[]
36
     */
37
    public $actions = [];
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function getTemplate()
43
    {
44
        return new TemplateMessageBuilder($this->altText, new ConfirmTemplateBuilder(
45
            $this->title,
46
            $this->createActions()
47
        ));
48
    }
49
50
    /**
51
     * @param string $label
52
     * @param string $text
53
     * @param string $type
54
     */
55
    public function addYesAction($label = 'Yes', $text = 'yes', $type = Action::TYPE_MESSAGE)
56
    {
57
        $this->actions[0] = new Action($label, $text, $type);
58
    }
59
60
    /**
61
     * @param string $label
62
     * @param string $text
63
     * @param string $type
64
     */
65
    public function addNoAction($label = 'No', $text = 'no', $type = Action::TYPE_MESSAGE)
66
    {
67
        $this->actions[1] = new Action($label, $text, $type);
68
    }
69
}
70