Completed
Push — master ( 0a6e40...a44d55 )
by Camilo
06:48
created

SendDocument::hasLocalFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace unreal4u\TelegramAPI\Telegram\Methods;
6
7
use Generator;
8
use unreal4u\TelegramAPI\Abstracts\KeyboardMethods;
9
use unreal4u\TelegramAPI\Abstracts\TelegramMethods;
10
use unreal4u\TelegramAPI\Telegram\Types\Custom\InputFile;
11
12
/**
13
 * Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any
14
 * type of up to 50 MB in size, this limit may be changed in the future.
15
 *
16
 * Objects defined as-is February 2018
17
 *
18
 * @see https://core.telegram.org/bots/api#senddocument
19
 */
20
class SendDocument extends TelegramMethods
21
{
22
    /**
23
     * Unique identifier for the target chat or username of the target channel (in the format @channelusername)
24
     * @var string
25
     */
26
    public $chat_id = '';
27
28
    /**
29
     * File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an
30
     * HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using the InputFile class
31
     *
32
     * @see InputFile
33
     * @var string|InputFile
34
     */
35
    public $document = '';
36
37
    /**
38
     * Optional. Document caption (may also be used when resending documents by file_id), 0-200 characters
39
     * @var string
40
     */
41
    public $caption = '';
42
43
    /**
44
     * Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs
45
     * in the media caption
46
     * @var string
47
     */
48
    public $parse_mode = '';
49
50
    /**
51
     * Optional. Sends the message silently. iOS users will not receive a notification, Android users will receive a
52
     * notification with no sound.
53
     * @see https://telegram.org/blog/channels-2-0#silent-messages
54
     * @var bool
55
     */
56
    public $disable_notification = false;
57
58
    /**
59
     * Optional. If the message is a reply, ID of the original message
60
     * @var int
61
     */
62
    public $reply_to_message_id = 0;
63
64
    /**
65
     * Optional. Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to
66
     * hide keyboard or to force a reply from the user
67
     * @var KeyboardMethods
68
     */
69
    public $reply_markup;
70
71 1
    public function getMandatoryFields(): array
72
    {
73
        return [
74 1
            'chat_id',
75
            'document',
76
        ];
77
    }
78
79 1
    public function hasLocalFiles(): bool
80
    {
81 1
        return $this->document instanceof InputFile;
82
    }
83
84 1
    public function getLocalFiles(): Generator
85
    {
86 1
        yield 'document' => $this->document;
87 1
    }
88
}
89