Completed
Pull Request — master (#53)
by Romain
03:15
created

AbstractButton::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Kerox\Messenger\Model\Common\Button;
4
5
use Kerox\Messenger\Helper\ValidatorTrait;
6
7
abstract class AbstractButton implements \JsonSerializable
8
{
9
10
    use ValidatorTrait;
11
12
    const TYPE_POSTBACK = 'postback';
13
    const TYPE_PHONE_NUMBER = 'phone_number';
14
    const TYPE_WEB_URL = 'web_url';
15
    const TYPE_SHARE = 'element_share';
16
    const TYPE_PAYMENT = 'payment';
17
    const TYPE_ACCOUNT_LINK = 'account_link';
18
    const TYPE_ACCOUNT_UNLINK = 'account_unlink';
19
    const TYPE_NESTED = 'nested';
20
21
    /**
22
     * @var string
23
     */
24
    private $type;
25
26
    /**
27
     * AbstractButton constructor.
28
     *
29
     * @param string $type
30
     */
31
    public function __construct(string $type)
32
    {
33
        $this->type = $type;
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getType(): string
40
    {
41
        return $this->type;
42
    }
43
44
    /**
45
     * @return array
46
     */
47
    public function jsonSerialize(): array
48
    {
49
        return [
50
            'type' => $this->type,
51
        ];
52
    }
53
}
54