InputMediaDocumentType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 39
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 2
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 InputMediaDocumentType.
12
 *
13
 * @see https://core.telegram.org/bots/api#inputmediadocument
14
 */
15
class InputMediaDocumentType extends InputMediaType
16
{
17
    use FillFromArrayTrait;
18
19
    /**
20
     * Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
21
     * A thumbnail‘s width and height should not exceed 90.
22
     * Ignored if the file is not uploaded using multipart/form-data.
23
     * Thumbnails can’t be reused and can be only uploaded as a new file,
24
     * so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using
25
     * multipart/form-data under <file_attach_name>.
26
     *
27
     * @var InputFileType|string|null
28
     */
29
    public $thumb;
30
31
    /**
32
     * Optional. Disables automatic server-side content type detection for files uploaded using multipart/form-data.
33
     * Always true, if the document is sent as part of an album.
34
     *
35
     * @var bool|null
36
     */
37
    public $disableContentTypeDetection;
38
39
    /**
40
     * @param string|InputFileType $media
41
     *
42
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
43
     */
44 2
    public static function create($media, array $data = null): InputMediaDocumentType
45
    {
46 2
        $instance = new static();
47 2
        $instance->media = $media;
48 2
        $instance->type = static::TYPE_DOCUMENT;
49 2
        if ($data) {
50 2
            $instance->fill($data, ['media', 'type']);
51
        }
52
53 2
        return $instance;
54
    }
55
}
56