Completed
Push — master ( 0a69d4...44fef3 )
by Camilo
03:25 queued 01:10
created

GetFile::bindToObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace unreal4u\TelegramAPI\Telegram\Methods;
6
7
use Psr\Log\LoggerInterface;
8
use unreal4u\TelegramAPI\Abstracts\TelegramMethods;
9
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
10
use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData;
11
use unreal4u\TelegramAPI\Telegram\Types\File;
12
13
/**
14
 * Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download
15
 * files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link
16
 * https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed
17
 * that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile
18
 * again.
19
 *
20
 * Objects defined as-is july 2016
21
 *
22
 * @see https://core.telegram.org/bots/api#getfile
23
 */
24
class GetFile extends TelegramMethods
25
{
26
    /**
27
     * File identifier to get info about
28
     * @var string
29
     */
30
    public $file_id = '';
31
32
    /**
33
     * This call will return an array with updates, so call up a custom type to do this
34
     *
35
     * @param TelegramRawData $data
36
     * @param LoggerInterface $logger
37
     * @return TelegramTypes
38
     */
39
    public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes
40
    {
41
        return new File($data->getResult(), $logger);
42
    }
43
44 1
    public function getMandatoryFields(): array
45
    {
46
        return [
47 1
            'file_id',
48
        ];
49
    }
50
}
51