GetFileMethod   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 5
dl 0
loc 20
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\MethodInterface;
8
9
/**
10
 * Class GetFileMethod.
11
 *
12
 * Use this method to get basic info about a file and prepare it for downloading.
13
 * For the moment, bots can download files of up to 20MB in size. On success, a File object is returned.
14
 * The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>,
15
 * where <file_path> is taken from the response.
16
 * It is guaranteed that the link will be valid for at least 1 hour.
17
 * When the link expires, a new one can be requested by calling getFile
18
 *
19
 * Note: This function may not preserve the original file name and MIME type.
20
 * You should save the file's MIME type and name (if available) when the File object is received.
21
 *
22
 * @see https://core.telegram.org/bots/api#getfile
23
 */
24
class GetFileMethod implements MethodInterface
25
{
26
    /**
27
     * File identifier to get info about.
28
     *
29
     * @var string
30
     */
31
    public $fileId;
32
33
    /**
34
     * @param string $fileId
35
     *
36
     * @return GetFileMethod
37
     */
38 2
    public static function create(string $fileId): GetFileMethod
39
    {
40 2
        $instance = new static();
41 2
        $instance->fileId = $fileId;
42
43 2
        return $instance;
44
    }
45
}
46