InlineQueryResultCachedDocumentType::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 16
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 4
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
use TgBotApi\BotApiBase\Type\Traits\CaptionEntitiesFieldTrait;
10
11
/**
12
 * Class InlineQueryResultCachedDocumentType.
13
 *
14
 * @see https://core.telegram.org/bots/api#inlinequeryresultcacheddocument
15
 */
16
class InlineQueryResultCachedDocumentType extends InlineQueryResultType
17
{
18
    use CaptionEntitiesFieldTrait;
19
    use FillFromArrayTrait;
20
21
    /**
22
     * Title for the result;.
23
     *
24
     * @var string
25
     */
26
    public $title;
27
28
    /**
29
     * A valid file identifier for the file.
30
     *
31
     * @var string
32
     */
33
    public $documentFileId;
34
35
    /**
36
     * Optional. Caption of the document to be sent, 0-1024 characters.
37
     *
38
     * @var string|null
39
     */
40
    public $caption;
41
42
    /**
43
     * Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic,
44
     * fixed-width text or inline URLs in the media caption.
45
     *
46
     * @var string|null
47
     */
48
    public $parseMode;
49
50
    /**
51
     * Optional. Short description of the result.
52
     *
53
     * @var string|null
54
     */
55
    public $description;
56
57
    /**
58
     * Optional. Content of the message to be sent instead of the file.
59
     *
60
     * @var InputMessageContentType|null
61
     */
62
    public $inputMessageContent;
63
64
    /**
65
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
66
     */
67
    public static function create(
68
        string $id,
69
        string $title,
70
        string $documentFileId,
71
        array $data = null
72
    ): InlineQueryResultCachedDocumentType {
73
        $instance = new static();
74
        $instance->type = static::TYPE_DOCUMENT;
75
        $instance->id = $id;
76
        $instance->title = $title;
77
        $instance->documentFileId = $documentFileId;
78
        if ($data) {
79
            $instance->fill($data);
80
        }
81
82
        return $instance;
83
    }
84
}
85