Passed
Push — master ( c05883...1d5c29 )
by Nikolay
02:30
created

InputMediaAnimationType::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Type\InputMedia;
6
7
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
8
use TgBotApi\BotApiBase\Type\InputFileType;
9
10
/**
11
 * Class InputMediaAnimationType.
12
 *
13
 * @see https://core.telegram.org/bots/api#inputmediaanimation
14
 */
15
class InputMediaAnimationType extends InputMediaType
16
{
17
    use FillFromArrayTrait;
18
    /**
19
     * Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
20
     * A thumbnail‘s width and height should not exceed 90.
21
     * Ignored if the file is not uploaded using multipart/form-data.
22
     * Thumbnails can’t be reused and can be only uploaded as a new file,
23
     * so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using
24
     * multipart/form-data under <file_attach_name>.
25
     *
26
     * @var InputFileType|string|null
27
     */
28
    public $thumb;
29
30
    /**
31
     * Optional. Animation width.
32
     *
33
     * @var int|null
34
     */
35
    public $width;
36
37
    /**
38
     * Optional. Animation height.
39
     *
40
     * @var int|null
41
     */
42
    public $height;
43
44
    /**
45
     * Optional. Animation duration.
46
     *
47
     * @var int|null
48
     */
49
    public $duration;
50
51
    /**
52
     * @param string|\SplFileInfo $media
53
     * @param array|null          $data
54
     *
55
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
56
     *
57
     * @return InputMediaAnimationType
58
     */
59
    public static function create($media, array $data = null): InputMediaAnimationType
60
    {
61
        $instance = new static();
62
        $instance->media = $media;
63
        $instance->type = static::TYPE_ANIMATION;
64
        if ($data) {
65
            $instance->fill($data);
66
        }
67
68
        return $instance;
69
    }
70
}
71