Completed
Push — master ( 7d37a2...fea370 )
by Nikolay
06:21
created

SendDocumentMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 40
ccs 4
cts 5
cp 0.8
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Greenplugin\TelegramBot\Method;
6
7
use Greenplugin\TelegramBot\Method\Interfaces\HasParseModeVariableInterface;
8
use Greenplugin\TelegramBot\Method\Traits\CaptionVariablesTrait;
9
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait;
10
use Greenplugin\TelegramBot\Method\Traits\SendToChatVariablesTrait;
11
use Greenplugin\TelegramBot\Type\InputFileType;
12
13
/**
14
 * Class SendDocumentMethod.
15
 *
16
 * @see https://core.telegram.org/bots/api#senddocument
17
 */
18
class SendDocumentMethod implements HasParseModeVariableInterface
19
{
20
    use FillFromArrayTrait;
21
    use SendToChatVariablesTrait;
22
    use CaptionVariablesTrait;
23
    /**
24
     * File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended),
25
     * pass an HTTP URL as a String for Telegram to get a file from the Internet,
26
     * or upload a new one using multipart/form-data.
27
     *
28
     * @var InputFileType|string
29
     */
30
    public $document;
31
32
    /**
33
     * Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
34
     * A thumbnail‘s width and height should not exceed 90.
35
     * Ignored if the file is not uploaded using multipart/form-data.
36
     * Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>”
37
     * if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files ».
38
     *
39
     * @var InputFileType|string|null
40
     */
41
    public $thumb;
42
43
    /**
44
     * SendDocumentMethod constructor.
45
     *
46
     * @param int|string           $chatId
47
     * @param InputFileType|string $document
48
     * @param array|null           $data
49
     *
50
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
51
     */
52 3
    public function __construct($chatId, $document, array $data = null)
53
    {
54 3
        $this->chatId = $chatId;
55 3
        $this->document = $document;
56 3
        if ($data) {
57
            $this->fill($data);
58
        }
59 3
    }
60
}
61