Passed
Push — master ( efef66...99edcd )
by
11:04
created

Row::addPostbackAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 2
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
13
namespace LineMob\Core\Template\Carousel;
14
15
use LineMob\Core\Template\Action;
16
17
/**
18
 * @author Ishmael Doss <[email protected]>
19
 */
20
class Row
21
{
22
    /**
23
     * @var string
24
     */
25
    public $thumbnail;
26
27
    /**
28
     * @var string
29
     */
30
    public $text;
31
32
    /**
33
     * @var string
34
     */
35
    public $title;
36
37
    /**
38
     * @var Action[]
39
     */
40
    public $actions;
41
42
    public function __construct($title, $text, $thumbnail, array $actions = [])
43
    {
44
        $this->title = $title;
45
        $this->text = $text;
46
        $this->thumbnail = $thumbnail;
47
48
        foreach ($actions as $action) {
49
            if (!$action instanceof Action) {
50
                $action = new Action($action['label'], $action['value']);
51
            }
52
53
            $this->actions[] = $action;
54
        }
55
    }
56
57
    /**
58
     * @param $label
59
     * @param $text
60
     */
61
    public function addMessageAction($label, $text)
62
    {
63
        $this->actions[] = new Action($label, $text, Action::TYPE_MESSAGE);
64
    }
65
66
    /**
67
     * @param $label
68
     * @param $link
69
     */
70
    public function addUriAction($label, $link)
71
    {
72
        $this->actions[] = new Action($label, $link, Action::TYPE_URI);
73
    }
74
75
    /**
76
     * @param $label
77
     * @param $data
78
     */
79
    public function addPostbackAction($label, $data)
80
    {
81
        $this->actions[] = new Action($label, $data, Action::TYPE_POSTBACK);
82
    }
83
}
84