Completed
Push — master ( 3347ae...8ec7fe )
by Romain
9s
created

PhoneNumber::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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