Completed
Pull Request — master (#55)
by Rick
03:55 queued 01:59
created

GetFile::bindToObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 2
crap 1
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\TelegramResponse;
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 TelegramResponse $data
36
     * @param LoggerInterface $logger
37
     * @return TelegramTypes
38
     */
39 1
    public static function bindToObject(TelegramResponse $data, LoggerInterface $logger): TelegramTypes
40
    {
41 1
        return new File($data->getResult(), $logger);
42
    }
43
44 2
    public function getMandatoryFields(): array
45
    {
46
        return [
47 2
            'file_id',
48
        ];
49
    }
50
}
51