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

InlineQueryResultCachedGifType::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 11
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Type\InlineQueryResult;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\HasParseModeVariableInterface;
8
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
9
use TgBotApi\BotApiBase\Type\InputMessageContent\InputMessageContentType;
10
11
/**
12
 * Class InlineQueryResultCachedGifType.
13
 *
14
 * Represents a link to an animated GIF file stored on the Telegram servers.
15
 * By default, this animated GIF file will be sent by the user with an optional caption.
16
 * Alternatively, you can use input_message_content to send a message with specified content instead of the animation.
17
 *
18
 * @see https://core.telegram.org/bots/api#inlinequeryresultcachedgif
19
 */
20
class InlineQueryResultCachedGifType extends InlineQueryResultType implements HasParseModeVariableInterface
21
{
22
    use FillFromArrayTrait;
23
24
    /**
25
     * A valid file identifier for the GIF file.
26
     *
27
     * @var string
28
     */
29
    public $gifFileId;
30
31
    /**
32
     * Optional. Title for the result.
33
     *
34
     * @var string|null
35
     */
36
    public $title;
37
38
    /**
39
     * Optional. Caption of the GIF file to be sent, 0-1024 characters.
40
     *
41
     * @var string|null
42
     */
43
    public $caption;
44
45
    /**
46
     * Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic,
47
     * fixed-width text or inline URLs in the media caption.
48
     *
49
     * @var string|null
50
     */
51
    public $parseMode;
52
53
    /**
54
     * Optional. Content of the message to be sent instead of the GIF animation.
55
     *
56
     * @var InputMessageContentType|null
57
     */
58
    public $inputMessageContent;
59
60
    /**
61
     * @param string     $id
62
     * @param string     $gifFileId
63
     * @param array|null $data
64
     *
65
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
66
     *
67
     * @return InlineQueryResultCachedGifType
68
     */
69
    public static function create(string $id, string $gifFileId, array $data = null): InlineQueryResultCachedGifType
70
    {
71
        $instance = new static();
72
        $instance->type = static::TYPE_GIF;
73
        $instance->id = $id;
74
        $instance->gifFileId = $gifFileId;
75
        if ($data) {
76
            $instance->fill($data);
77
        }
78
79
        return $instance;
80
    }
81
}
82