Completed
Push — master ( 588078...30ae0c )
by Nikolay
04:51 queued 02:15
created

InlineQueryResultDocumentType   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 99
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 21
dl 0
loc 99
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Greenplugin\TelegramBot\Type\InlineQueryResult;
6
7
use Greenplugin\TelegramBot\Method\Interfaces\HasParseModeVariableInterface;
8
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait;
9
use Greenplugin\TelegramBot\Type\InputMessageContent\InputMessageContentType;
10
11
/**
12
 * Class InlineQueryResultDocumentType.
13
 *
14
 * Represents a link to a file. By default, this file will be sent by the user with an optional caption.
15
 * Alternatively, you can use input_message_content to send a message with the specified content instead of the file.
16
 * Currently, only .PDF and .ZIP files can be sent using this method.
17
 *
18
 * @see https://core.telegram.org/bots/api#inlinequeryresultdocument
19
 */
20
class InlineQueryResultDocumentType extends InlineQueryResultType implements HasParseModeVariableInterface
21
{
22
    use FillFromArrayTrait;
23
    const MIME_TYPE_PDF = 'application/pdf';
24
    const MIME_TYPE_ZIP = 'application/zip';
25
26
    /**
27
     * Title for the result;.
28
     *
29
     * @var string
30
     */
31
    public $title;
32
33
    /**
34
     * A valid URL for the file.
35
     *
36
     * @var string
37
     */
38
    public $documentUrl;
39
40
    /**
41
     * Mime type of the content of the file, either “application/pdf” or “application/zip”.
42
     *
43
     * @var string
44
     *
45
     * @see InlineQueryResultDocumentType::MIME_TYPE_PDF, InlineQueryResultDocumentType::MIME_TYPE_ZIP
46
     */
47
    public $mimeType;
48
49
    /**
50
     * Optional. Caption of the document to be sent, 0-1024 characters.
51
     *
52
     * @var string|null
53
     */
54
    public $caption;
55
56
    /**
57
     * Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic,
58
     * fixed-width text or inline URLs in the media caption.
59
     *
60
     * @var string|null
61
     */
62
    public $parseMode;
63
64
    /**
65
     * Optional. Short description of the result.
66
     *
67
     * @var string|null
68
     */
69
    public $description;
70
71
    /**
72
     * Optional. Content of the message to be sent instead of the file.
73
     *
74
     * @var InputMessageContentType|null
75
     */
76
    public $inputMessageContent;
77
78
    /**
79
     * Optional. URL of the thumbnail (jpeg only) for the file.
80
     *
81
     * @var string|null
82
     */
83
    public $thumbUrl;
84
85
    /**
86
     * Optional. Thumbnail width.
87
     *
88
     * @var int|null
89
     */
90
    public $thumbWidth;
91
92
    /**
93
     * Optional. Thumbnail height.
94
     *
95
     * @var int|null
96
     */
97
    public $thumbHeight;
98
99
    /**
100
     * InlineQueryResultDocumentType constructor.
101
     *
102
     * @param string     $id
103
     * @param string     $title
104
     * @param string     $documentUrl
105
     * @param string     $mimeType
106
     * @param array|null $data
107
     *
108
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
109
     */
110
    public function __construct(string $id, string $title, string $documentUrl, string $mimeType, array $data = null)
111
    {
112
        $this->type = self::TYPE_DOCUMENT;
113
        $this->id = $id;
114
        $this->title = $title;
115
        $this->documentUrl = $documentUrl;
116
        $this->$mimeType = $mimeType;
117
        if ($data) {
118
            $this->fill($data);
119
        }
120
    }
121
}
122