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

StartButton::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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