Passed
Push — master ( 59a435...62cb7b )
by Nikolay
11:22
created

SendAnimationMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 15
dl 0
loc 66
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\HasParseModeVariableInterface;
8
use TgBotApi\BotApiBase\Method\Traits\CaptionVariablesTrait;
9
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
10
use TgBotApi\BotApiBase\Method\Traits\SendToChatVariablesTrait;
11
use TgBotApi\BotApiBase\Type\InputFileType;
12
13
/**
14
 * Class SendAnimationMethod.
15
 *
16
 * @see https://core.telegram.org/bots/api#sendanimation
17
 */
18
class SendAnimationMethod implements HasParseModeVariableInterface
19
{
20
    use FillFromArrayTrait;
21
    use SendToChatVariablesTrait;
22
    use CaptionVariablesTrait;
23
    /**
24
     * Animation to send.
25
     * Pass a file_id as String to send an animation that exists on the Telegram servers (recommended),
26
     * pass an HTTP URL as a String for Telegram to get an animation from the Internet,
27
     * or upload a new animation using multipart/form-data.
28
     *
29
     * @var InputFileType|string
30
     */
31
    public $animation;
32
33
    /**
34
     * Optional. Duration of sent video in seconds.
35
     *
36
     * @var int|null
37
     */
38
    public $duration;
39
40
    /**
41
     * Optional. Animation width.
42
     *
43
     * @var int|null
44
     */
45
    public $width;
46
47
    /**
48
     * Optional. Animation height.
49
     *
50
     * @var int|null
51
     */
52
    public $height;
53
54
    /**
55
     * Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
56
     * A thumbnail‘s width and height should not exceed 90.
57
     * Ignored if the file is not uploaded using multipart/form-data.
58
     * Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>”
59
     * if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
60
     *
61
     * @var InputFileType|string|null
62
     */
63
    public $thumb;
64
65
    /**
66
     * @param int|string           $chatId
67
     * @param InputFileType|string $animation
68
     * @param array|null           $data
69
     *
70
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
71
     *
72
     * @return SendAnimationMethod
73
     */
74 2
    public static function create($chatId, $animation, array $data = null): SendAnimationMethod
75
    {
76 2
        $instance = new static();
77 2
        $instance->chatId = $chatId;
78 2
        $instance->animation = $animation;
79 2
        if ($data) {
80 1
            $instance->fill($data);
81
        }
82
83 2
        return $instance;
84
    }
85
}
86