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

PhoneNumber   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 44
ccs 12
cts 12
cp 1
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 2
    public function __construct(string $title, string $payload)
25
    {
26 2
        parent::__construct(self::TYPE_PHONE_NUMBER);
27
28 2
        $this->isValidString($title, 20);
29 2
        $this->isValidString($payload, 1000);
30
31 2
        $this->title = $title;
32 2
        $this->payload = $payload;
33 2
    }
34
35
    /**
36
     * @return array
37
     */
38 1
    public function jsonSerialize(): array
39
    {
40 1
        $json = parent::jsonSerialize();
41
        $json += [
42 1
            'title' => $this->title,
43 1
            'payload' => $this->payload,
44
        ];
45
46 1
        return $json;
47
    }
48
}
49