Completed
Push — master ( e9be36...9488e8 )
by Camilo
04:57
created

GetFile   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 18
ccs 2
cts 2
cp 1
rs 10
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 array $data
36
     * @param LoggerInterface $logger
37
     * @return TelegramTypes
38
     */
39 1
    public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes
40
    {
41 1
        return new File($data->getResult(), $logger);
42
    }
43
}
44