PushMessageContentVideo::typeSerialize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This phpFile is auto-generated.
5
 */
6
7
declare(strict_types=1);
8
9
namespace PHPTdGram\Schema;
10
11
/**
12
 * A video message.
13
 */
14
class PushMessageContentVideo extends PushMessageContent
15
{
16
    public const TYPE_NAME = 'pushMessageContentVideo';
17
18
    /**
19
     * Message content; may be null.
20
     */
21
    protected ?Video $video;
22
23
    /**
24
     * Video caption.
25
     */
26
    protected string $caption;
27
28
    /**
29
     * True, if the video is secret.
30
     */
31
    protected bool $isSecret;
32
33
    /**
34
     * True, if the message is a pinned message with the specified content.
35
     */
36
    protected bool $isPinned;
37
38
    public function __construct(?Video $video, string $caption, bool $isSecret, bool $isPinned)
39
    {
40
        parent::__construct();
41
42
        $this->video    = $video;
43
        $this->caption  = $caption;
44
        $this->isSecret = $isSecret;
45
        $this->isPinned = $isPinned;
46
    }
47
48
    public static function fromArray(array $array): PushMessageContentVideo
49
    {
50
        return new static(
51
            (isset($array['video']) ? TdSchemaRegistry::fromArray($array['video']) : null),
52
            $array['caption'],
53
            $array['is_secret'],
54
            $array['is_pinned'],
55
        );
56
    }
57
58
    public function typeSerialize(): array
59
    {
60
        return [
61
            '@type'     => static::TYPE_NAME,
62
            'video'     => (isset($this->video) ? $this->video : null),
63
            'caption'   => $this->caption,
64
            'is_secret' => $this->isSecret,
65
            'is_pinned' => $this->isPinned,
66
        ];
67
    }
68
69
    public function getVideo(): ?Video
70
    {
71
        return $this->video;
72
    }
73
74
    public function getCaption(): string
75
    {
76
        return $this->caption;
77
    }
78
79
    public function getIsSecret(): bool
80
    {
81
        return $this->isSecret;
82
    }
83
84
    public function getIsPinned(): bool
85
    {
86
        return $this->isPinned;
87
    }
88
}
89