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

GetFile   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 27
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A bindToObject() 0 4 1
A getMandatoryFields() 0 6 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