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

PhoneNumber::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 2
crap 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