File::setFileId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace TelegramBot\Api\Types;
4
5
use TelegramBot\Api\BaseType;
6
use TelegramBot\Api\InvalidArgumentException;
7
use TelegramBot\Api\TypeInterface;
8
9
/**
10
 * Class File
11
 * This object represents a file ready to be downloaded.
12
 * The file can be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>.
13
 * It is guaranteed that the link will be valid for at least 1 hour.
14
 * When the link expires, a new one can be requested by calling getFile.
15
 *
16
 * @package TelegramBot\Api\Types
17
 */
18
class File extends BaseType implements TypeInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     *
23
     * @var array
24
     */
25
    protected static $requiredParams = ['file_id'];
26
27
    /**
28
     * {@inheritdoc}
29
     *
30
     * @var array
31
     */
32
    protected static $map = [
33
        'file_id' => true,
34
        'file_unique_id' => true,
35
        'file_size' => true,
36
        'file_path' => true
37
    ];
38
39
    /**
40
     * Unique identifier for this file
41
     *
42
     * @var string
43
     */
44
    protected $fileId;
45
46
    /**
47
     * Optional. File size, if known
48
     *
49
     * @var int|null
50
     */
51
    protected $fileSize;
52
53
    /**
54
     * Optional. File path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file.
55
     *
56
     * @var string|null
57
     */
58
    protected $filePath;
59
60
    /**
61
     * Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
62
     *
63
     * @var string
64
     */
65
    protected $fileUniqueId;
66
67
    /**
68
     * @return string
69
     */
70 1
    public function getFileId()
71
    {
72 1
        return $this->fileId;
73
    }
74
75
    /**
76
     * @param string $fileId
77
     * @return void
78 3
     */
79
    public function setFileId($fileId)
80 3
    {
81 3
        $this->fileId = $fileId;
82
    }
83
84
    /**
85
     * @return int|null
86 1
     */
87
    public function getFileSize()
88 1
    {
89
        return $this->fileSize;
90
    }
91
92
    /**
93
     * @param mixed $fileSize
94
     * @return void
95
     * @throws InvalidArgumentException
96 4
     */
97
    public function setFileSize($fileSize)
98 4
    {
99 3
        if (is_integer($fileSize)) {
100 3
            $this->fileSize = $fileSize;
101 1
        } else {
102
            throw new InvalidArgumentException();
103 3
        }
104
    }
105
106
    /**
107
     * @return null|string
108 1
     */
109
    public function getFilePath()
110 1
    {
111
        return $this->filePath;
112
    }
113
114
    /**
115
     * @param string $filePath
116 3
     * @return void
117
     */
118 3
    public function setFilePath($filePath)
119 3
    {
120
        $this->filePath = $filePath;
121
    }
122
123
    /**
124
     * @return string
125
     */
126
    public function getFileUniqueId()
127
    {
128
        return $this->fileUniqueId;
129
    }
130
131
    /**
132
     * @param string $fileUniqueId
133
     * @return void
134
     */
135
    public function setFileUniqueId($fileUniqueId)
136
    {
137
        $this->fileUniqueId = $fileUniqueId;
138
    }
139
}
140