InlineQueryResultVideoType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 114
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 23
dl 0
loc 114
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Greenplugin\TelegramBot\Type\InlineQueryResult;
6
7
use Greenplugin\TelegramBot\Method\Interfaces\HasParseModeVariableInterface;
8
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait;
9
use Greenplugin\TelegramBot\Type\InputMessageContent\InputMessageContentType;
10
11
/**
12
 * Class InlineQueryResultVideoType
13
 * Represents a link to a page containing an embedded video player or a video file.
14
 * By default, this video file will be sent by the user with an optional caption.
15
 * Alternatively, you can use input_message_content to send a message with the specified content instead of the video.
16
 *
17
 * If an InlineQueryResultVideo message contains an embedded video (e.g., YouTube),
18
 * you must replace its content using inputMessageContent.
19
 *
20
 * @see https://core.telegram.org/bots/api#inlinequeryresultvideo
21
 */
22
class InlineQueryResultVideoType extends InlineQueryResultType implements HasParseModeVariableInterface
23
{
24
    use FillFromArrayTrait;
25
    const MIME_TYPE_TEXT = 'text/html';
26
    const MIME_TYPE_VIDEO = 'video/mp4';
27
28
    /**
29
     * A valid URL for the embedded video player or video file.
30
     *
31
     * @var string
32
     */
33
    public $video;
34
35
    /**
36
     * Mime type of the content of video url, “text/html” or “video/mp4”.
37
     *
38
     * @var string
39
     */
40
    public $mimeType;
41
42
    /**
43
     * URL of the thumbnail (jpeg only) for the video;.
44
     *
45
     * @var string
46
     */
47
    public $thumbUrl;
48
49
    /**
50
     * Title for the result.
51
     *
52
     * @var string
53
     */
54
    public $title;
55
56
    /**
57
     * Optional. Caption of the video to be sent, 0-1024 characters.
58
     *
59
     * @var string|null
60
     */
61
    public $caption;
62
63
    /**
64
     * Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic,
65
     * fixed-width text or inline URLs in the media caption.
66
     *
67
     * @var string|null
68
     */
69
    public $parseMode;
70
71
    /**
72
     * Optional. Video width.
73
     *
74
     * @var int|null
75
     */
76
    public $videoWidth;
77
78
    /**
79
     * Optional. Video height.
80
     *
81
     * @var int|null
82
     */
83
    public $videoHeight;
84
85
    /**
86
     * Optional. Video duration in seconds.
87
     *
88
     * @var int|null
89
     */
90
    public $videoDuration;
91
92
    /**
93
     * Optional. Short description of the result.
94
     *
95
     * @var string|null
96
     */
97
    public $description;
98
99
    /**
100
     * Optional. Content of the message to be sent instead of the video.
101
     * This field is required if InlineQueryResultVideo is used to send an HTML-page as a result
102
     * (e.g., a YouTube video).
103
     *
104
     * @var InputMessageContentType|null
105
     */
106
    public $inputMessageContent;
107
108
    /**
109
     * InlineQueryResultVideoType constructor.
110
     *
111
     * @param string     $id
112
     * @param string     $video
113
     * @param string     $mimeType
114
     * @param string     $thumbUrl
115
     * @param string     $title
116
     * @param array|null $data
117
     *
118
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
119
     */
120
    public function __construct(
121
        string $id,
122
        string $video,
123
        string $mimeType,
124
        string $thumbUrl,
125
        string $title,
126
        array $data = null
127
    ) {
128
        $this->type = self::TYPE_VIDEO;
129
        $this->id = $id;
130
        $this->video = $video;
131
        $this->mimeType = $mimeType;
132
        $this->thumbUrl = $thumbUrl;
133
        $this->title = $title;
134
        if ($data) {
135
            $this->fill($data);
136
        }
137
    }
138
}
139