Passed
Push — master ( 8ed01e...08cfff )
by Romain
02:40
created

AbstractButton   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 47
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getType() 0 4 1
A jsonSerialize() 0 6 1
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 18
    public function __construct(string $type)
32
    {
33 18
        $this->type = $type;
34 18
    }
35
36
    /**
37
     * @return string
38
     */
39 6
    public function getType(): string
40
    {
41 6
        return $this->type;
42
    }
43
44
    /**
45
     * @return array
46
     */
47 14
    public function jsonSerialize(): array
48
    {
49
        return [
50 14
            'type' => $this->type,
51
        ];
52
    }
53
}
54