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

PhoneNumber   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 44
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A jsonSerialize() 0 10 1
1
<?php
2
3
namespace Kerox\Messenger\Model\Common\Button;
4
5
class PhoneNumber extends AbstractButton
6
{
7
8
    /**
9
     * @var string
10
     */
11
    protected $title;
12
13
    /**
14
     * @var string
15
     */
16
    protected $payload;
17
18
    /**
19
     * PhoneNumber constructor.
20
     *
21
     * @param string $title
22
     * @param string $payload
23
     */
24
    public function __construct(string $title, string $payload)
25
    {
26
        parent::__construct(self::TYPE_PHONE_NUMBER);
27
28
        $this->isValidString($title, 20);
29
        $this->isValidString($payload, 1000);
30
31
        $this->title = $title;
32
        $this->payload = $payload;
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    public function jsonSerialize(): array
39
    {
40
        $json = parent::jsonSerialize();
41
        $json += [
42
            'title' => $this->title,
43
            'payload' => $this->payload,
44
        ];
45
46
        return $json;
47
    }
48
}
49