Passed
Pull Request — master (#408)
by Alexander
01:43
created

File::setFileId()   A

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
    static protected $requiredParams = ['file_id'];
26
27
    /**
28
     * {@inheritdoc}
29
     *
30
     * @var array
31
     */
32
    static protected $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
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
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
     */
78 3
    public function setFileId($fileId)
79
    {
80 3
        $this->fileId = $fileId;
81 3
    }
82
83
    /**
84
     * @return int
85
     */
86 1
    public function getFileSize()
87
    {
88 1
        return $this->fileSize;
89
    }
90
91
    /**
92
     * @param int $fileSize
93
     *
94
     * @throws InvalidArgumentException
95
     */
96 4
    public function setFileSize($fileSize)
97
    {
98 4
        if (is_integer($fileSize)) {
0 ignored issues
show
introduced by
The condition is_integer($fileSize) is always true.
Loading history...
99 3
            $this->fileSize = $fileSize;
100 3
        } else {
101 1
            throw new InvalidArgumentException();
102
        }
103 3
    }
104
105
    /**
106
     * @return string
107
     */
108 1
    public function getFilePath()
109
    {
110 1
        return $this->filePath;
111
    }
112
113
    /**
114
     * @param string $filePath
115
     */
116 3
    public function setFilePath($filePath)
117
    {
118 3
        $this->filePath = $filePath;
119 3
    }
120
121
    /**
122
     * @return string
123
     */
124
    public function getFileUniqueId()
125
    {
126
        return $this->fileUniqueId;
127
    }
128
129
    /**
130
     * @param string $fileUniqueId
131
     */
132
    public function setFileUniqueId($fileUniqueId)
133
    {
134
        $this->fileUniqueId = $fileUniqueId;
135
    }
136
}
137