AbstractButton   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getType() 0 4 1
A toArray() 0 6 1
A jsonSerialize() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model\Common\Button;
6
7
use Kerox\Messenger\Helper\ValidatorTrait;
8
9
abstract class AbstractButton implements \JsonSerializable
10
{
11
    use ValidatorTrait;
12
13
    public const TYPE_POSTBACK = 'postback';
14
    public const TYPE_PHONE_NUMBER = 'phone_number';
15
    public const TYPE_WEB_URL = 'web_url';
16
    public const TYPE_PAYMENT = 'payment';
17
    public const TYPE_ACCOUNT_LINK = 'account_link';
18
    public const TYPE_ACCOUNT_UNLINK = 'account_unlink';
19
20
    /** @deprecated Since version 3.3.1 and will be removed in version 4.0.0. */
21
    public const TYPE_SHARE = 'element_share';
22
23
    /** @deprecated Since version 3.3.1 and will be removed in version 4.0.0. */
24
    public const TYPE_NESTED = 'nested';
25
26
    /**
27
     * @var string
28
     */
29
    private $type;
30
31
    /**
32
     * AbstractButton constructor.
33
     */
34 20
    public function __construct(string $type)
35
    {
36 20
        $this->type = $type;
37 20
    }
38
39 7
    public function getType(): string
40
    {
41 7
        return $this->type;
42
    }
43
44 15
    public function toArray(): array
45
    {
46
        return [
47 15
            'type' => $this->type,
48
        ];
49
    }
50
51 15
    public function jsonSerialize(): array
52
    {
53 15
        return $this->toArray();
54
    }
55
}
56