InputInlineQueryResultVideo::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 11
dl 0
loc 26
rs 9.8666
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
/**
4
 * This phpFile is auto-generated.
5
 */
6
7
declare(strict_types=1);
8
9
namespace AurimasNiekis\TdLibSchema;
10
11
/**
12
 * Represents a link to a page containing an embedded video player or a video file.
13
 */
14
class InputInlineQueryResultVideo extends InputInlineQueryResult
15
{
16
    public const TYPE_NAME = 'inputInlineQueryResultVideo';
17
18
    /**
19
     * Unique identifier of the query result.
20
     *
21
     * @var string
22
     */
23
    protected string $id;
24
25
    /**
26
     * Title of the result.
27
     *
28
     * @var string
29
     */
30
    protected string $title;
31
32
    /**
33
     * A short description of the result, if known.
34
     *
35
     * @var string
36
     */
37
    protected string $description;
38
39
    /**
40
     * The URL of the video thumbnail (JPEG), if it exists.
41
     *
42
     * @var string
43
     */
44
    protected string $thumbnailUrl;
45
46
    /**
47
     * URL of the embedded video player or video file.
48
     *
49
     * @var string
50
     */
51
    protected string $videoUrl;
52
53
    /**
54
     * MIME type of the content of the video URL, only "text/html" or "video/mp4" are currently supported.
55
     *
56
     * @var string
57
     */
58
    protected string $mimeType;
59
60
    /**
61
     * Width of the video.
62
     *
63
     * @var int
64
     */
65
    protected int $videoWidth;
66
67
    /**
68
     * Height of the video.
69
     *
70
     * @var int
71
     */
72
    protected int $videoHeight;
73
74
    /**
75
     * Video duration, in seconds.
76
     *
77
     * @var int
78
     */
79
    protected int $videoDuration;
80
81
    /**
82
     * The message reply markup. Must be of type replyMarkupInlineKeyboard or null.
83
     *
84
     * @var ReplyMarkup
85
     */
86
    protected ReplyMarkup $replyMarkup;
87
88
    /**
89
     * The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageVideo, InputMessageLocation, InputMessageVenue or InputMessageContact.
90
     *
91
     * @var InputMessageContent
92
     */
93
    protected InputMessageContent $inputMessageContent;
94
95
    public function __construct(
96
        string $id,
97
        string $title,
98
        string $description,
99
        string $thumbnailUrl,
100
        string $videoUrl,
101
        string $mimeType,
102
        int $videoWidth,
103
        int $videoHeight,
104
        int $videoDuration,
105
        ReplyMarkup $replyMarkup,
106
        InputMessageContent $inputMessageContent
107
    ) {
108
        parent::__construct();
109
110
        $this->id                  = $id;
111
        $this->title               = $title;
112
        $this->description         = $description;
113
        $this->thumbnailUrl        = $thumbnailUrl;
114
        $this->videoUrl            = $videoUrl;
115
        $this->mimeType            = $mimeType;
116
        $this->videoWidth          = $videoWidth;
117
        $this->videoHeight         = $videoHeight;
118
        $this->videoDuration       = $videoDuration;
119
        $this->replyMarkup         = $replyMarkup;
120
        $this->inputMessageContent = $inputMessageContent;
121
    }
122
123
    public static function fromArray(array $array): InputInlineQueryResultVideo
124
    {
125
        return new static(
126
            $array['id'],
127
            $array['title'],
128
            $array['description'],
129
            $array['thumbnail_url'],
130
            $array['video_url'],
131
            $array['mime_type'],
132
            $array['video_width'],
133
            $array['video_height'],
134
            $array['video_duration'],
135
            TdSchemaRegistry::fromArray($array['reply_markup']),
136
            TdSchemaRegistry::fromArray($array['input_message_content']),
137
        );
138
    }
139
140
    public function typeSerialize(): array
141
    {
142
        return [
143
            '@type'                 => static::TYPE_NAME,
144
            'id'                    => $this->id,
145
            'title'                 => $this->title,
146
            'description'           => $this->description,
147
            'thumbnail_url'         => $this->thumbnailUrl,
148
            'video_url'             => $this->videoUrl,
149
            'mime_type'             => $this->mimeType,
150
            'video_width'           => $this->videoWidth,
151
            'video_height'          => $this->videoHeight,
152
            'video_duration'        => $this->videoDuration,
153
            'reply_markup'          => $this->replyMarkup->typeSerialize(),
154
            'input_message_content' => $this->inputMessageContent->typeSerialize(),
155
        ];
156
    }
157
158
    public function getId(): string
159
    {
160
        return $this->id;
161
    }
162
163
    public function getTitle(): string
164
    {
165
        return $this->title;
166
    }
167
168
    public function getDescription(): string
169
    {
170
        return $this->description;
171
    }
172
173
    public function getThumbnailUrl(): string
174
    {
175
        return $this->thumbnailUrl;
176
    }
177
178
    public function getVideoUrl(): string
179
    {
180
        return $this->videoUrl;
181
    }
182
183
    public function getMimeType(): string
184
    {
185
        return $this->mimeType;
186
    }
187
188
    public function getVideoWidth(): int
189
    {
190
        return $this->videoWidth;
191
    }
192
193
    public function getVideoHeight(): int
194
    {
195
        return $this->videoHeight;
196
    }
197
198
    public function getVideoDuration(): int
199
    {
200
        return $this->videoDuration;
201
    }
202
203
    public function getReplyMarkup(): ReplyMarkup
204
    {
205
        return $this->replyMarkup;
206
    }
207
208
    public function getInputMessageContent(): InputMessageContent
209
    {
210
        return $this->inputMessageContent;
211
    }
212
}
213