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

Share::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Kerox\Messenger\Model\Common\Button;
4
5
use Kerox\Messenger\Helper\UtilityTrait;
6
use Kerox\Messenger\Model\Message\Attachment\Template\Generic;
7
8
class Share extends AbstractButton
9
{
10
11
    use UtilityTrait;
12
13
    /**
14
     * @var null|\Kerox\Messenger\Model\Message\Attachment\Template\Generic
15
     */
16
    protected $content;
17
18
    /**
19
     * Share constructor.
20
     * @param \Kerox\Messenger\Model\Message\Attachment\Template\Generic $content
21
     */
22
    public function __construct(Generic $content = null)
23
    {
24
        parent::__construct(self::TYPE_SHARE);
25
26
        $this->content = $content;
27
    }
28
29
    /**
30
     * @return array
31
     */
32
    public function jsonSerialize(): array
33
    {
34
        $json = parent::jsonSerialize();
35
        $json += [
36
            'share_contents' => [
37
                'attachment' => $this->content,
38
            ],
39
        ];
40
41
        return $this->arrayFilter($json);
42
    }
43
}
44