InlineQueryResultCachedStickerType::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
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 14
ccs 0
cts 13
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\Traits\FillFromArrayTrait;
8
use TgBotApi\BotApiBase\Type\InputMessageContent\InputMessageContentType;
9
10
/**
11
 * Class InlineQueryResultCachedStickerType.
12
 *
13
 * @see https://core.telegram.org/bots/api#inlinequeryresultcachedsticker
14
 */
15
class InlineQueryResultCachedStickerType extends InlineQueryResultType
16
{
17
    use FillFromArrayTrait;
18
19
    /**
20
     * A valid file identifier of the sticker.
21
     *
22
     * @var string
23
     */
24
    public $stickerFileId;
25
26
    /**
27
     * Optional. Content of the message to be sent instead of the sticker.
28
     *
29
     * @var InputMessageContentType|null
30
     */
31
    public $inputMessageContent;
32
33
    /**
34
     * @param string     $id
35
     * @param string     $stickerFileId
36
     * @param array|null $data
37
     *
38
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
39
     *
40
     * @return InlineQueryResultCachedStickerType
41
     */
42
    public static function create(
43
        string $id,
44
        string $stickerFileId,
45
        array $data = null
46
    ): InlineQueryResultCachedStickerType {
47
        $instance = new static();
48
        $instance->type = static::TYPE_STICKER;
49
        $instance->id = $id;
50
        $instance->stickerFileId = $stickerFileId;
51
        if ($data) {
52
            $instance->fill($data);
53
        }
54
55
        return $instance;
56
    }
57
}
58