SendVideoNoteMethod::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\SendMethodAliasInterface;
8
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
9
use TgBotApi\BotApiBase\Method\Traits\SendToChatVariablesTrait;
10
use TgBotApi\BotApiBase\Type\InputFileType;
11
12
/**
13
 * Class SendVideoNoteMethod.
14
 *
15
 * @see https://core.telegram.org/bots/api#sendvideonote
16
 */
17
class SendVideoNoteMethod implements SendMethodAliasInterface
18
{
19
    use FillFromArrayTrait;
20
    use SendToChatVariablesTrait;
21
    /**
22
     * Video note to send.
23
     * Pass a file_id as String to send a video note that exists on the Telegram servers (recommended)
24
     * or upload a new video using multipart/form-data.
25
     * Sending video notes by a URL is currently unsupported.
26
     *
27
     * @var InputFileType|string
28
     */
29
    public $videoNote;
30
31
    /**
32
     * Optional. Duration of sent video in seconds.
33
     *
34
     * @var int|null
35
     */
36
    public $duration;
37
38
    /**
39
     * Optional. Video width and height, i.e. diameter of the video message.
40
     *
41
     * @var int|null
42
     */
43
    public $length;
44
45
    /**
46
     * Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
47
     * A thumbnail‘s width and height should not exceed 90.
48
     * Ignored if the file is not uploaded using multipart/form-data.
49
     * Thumbnails can’t be reused and can be only uploaded as a new file,
50
     * so you can pass “attach://<file_attach_name>”
51
     * if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
52
     *
53
     * @var InputFileType|string|null
54
     */
55
    public $thumb;
56
57
    /**
58
     * @param int|string           $chatId
59
     * @param InputFileType|string $videoNote
60
     * @param array|null           $data
61
     *
62
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
63
     *
64
     * @return SendVideoNoteMethod
65
     */
66 2
    public static function create($chatId, $videoNote, array $data = null): SendVideoNoteMethod
67
    {
68 2
        $instance = new static();
69 2
        $instance->chatId = $chatId;
70 2
        $instance->videoNote = $videoNote;
71 2
        if ($data) {
72 1
            $instance->fill($data);
73
        }
74
75 2
        return $instance;
76
    }
77
}
78