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 Document |
11
|
|
|
* This object represents a general file (as opposed to photos and audio files). |
12
|
|
|
* Telegram users can send files of any type of up to 1.5 GB in size. |
13
|
|
|
* |
14
|
|
|
* @package TelegramBot\Api\Types |
15
|
|
|
*/ |
16
|
|
|
class Document extends BaseType implements TypeInterface |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* {@inheritdoc} |
21
|
|
|
* |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
static protected $requiredParams = ['file_id']; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
* |
29
|
|
|
* @var array |
30
|
|
|
*/ |
31
|
|
|
static protected $map = [ |
32
|
|
|
'file_id' => true, |
33
|
|
|
'file_unique_id' => true, |
34
|
|
|
'thumb' => PhotoSize::class, |
35
|
|
|
'file_name' => true, |
36
|
|
|
'mime_type' => true, |
37
|
|
|
'file_size' => true |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Identifier for this file, which can be used to download or reuse the file |
42
|
|
|
* |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
protected $fileId; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Unique identifier for this file, which is supposed |
49
|
|
|
* to be thesame over time and for different bots. |
50
|
|
|
* Can't be used to download or reuse the file. |
51
|
|
|
* |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
protected $fileUniqueId; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Document thumbnail as defined by sender |
58
|
|
|
* |
59
|
|
|
* @var PhotoSize |
60
|
|
|
*/ |
61
|
|
|
protected $thumb; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Optional. Original filename as defined by sender |
65
|
|
|
* |
66
|
|
|
* @var string |
67
|
|
|
*/ |
68
|
|
|
protected $fileName; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Optional. MIME type of the file as defined by sender |
72
|
|
|
* |
73
|
|
|
* @var string |
74
|
|
|
*/ |
75
|
|
|
protected $mimeType; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Optional. File size |
79
|
|
|
* |
80
|
|
|
* @var int |
81
|
|
|
*/ |
82
|
|
|
protected $fileSize; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
1 |
|
public function getFileId() |
88
|
|
|
{ |
89
|
1 |
|
return $this->fileId; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param string $fileId |
94
|
|
|
*/ |
95
|
5 |
|
public function setFileId($fileId) |
96
|
|
|
{ |
97
|
5 |
|
$this->fileId = $fileId; |
98
|
5 |
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return string |
102
|
|
|
*/ |
103
|
|
|
public function getFileUniqueId() |
104
|
|
|
{ |
105
|
|
|
return $this->fileUniqueId; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param string $fileId |
|
|
|
|
110
|
|
|
*/ |
111
|
|
|
public function setFileUniqueId($fileUniqueId) |
112
|
|
|
{ |
113
|
|
|
$this->fileUniqueId = $fileUniqueId; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return string |
118
|
|
|
*/ |
119
|
1 |
|
public function getFileName() |
120
|
|
|
{ |
121
|
1 |
|
return $this->fileName; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @param string $fileName |
126
|
|
|
*/ |
127
|
5 |
|
public function setFileName($fileName) |
128
|
|
|
{ |
129
|
5 |
|
$this->fileName = $fileName; |
130
|
5 |
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return int |
134
|
|
|
*/ |
135
|
1 |
|
public function getFileSize() |
136
|
|
|
{ |
137
|
1 |
|
return $this->fileSize; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @param int $fileSize |
142
|
|
|
* |
143
|
|
|
* @throws InvalidArgumentException |
144
|
|
|
*/ |
145
|
6 |
|
public function setFileSize($fileSize) |
146
|
|
|
{ |
147
|
6 |
|
if (is_integer($fileSize)) { |
148
|
5 |
|
$this->fileSize = $fileSize; |
149
|
5 |
|
} else { |
150
|
1 |
|
throw new InvalidArgumentException(); |
151
|
|
|
} |
152
|
5 |
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @return string |
156
|
|
|
*/ |
157
|
1 |
|
public function getMimeType() |
158
|
|
|
{ |
159
|
1 |
|
return $this->mimeType; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @param string $mimeType |
164
|
|
|
*/ |
165
|
5 |
|
public function setMimeType($mimeType) |
166
|
|
|
{ |
167
|
5 |
|
$this->mimeType = $mimeType; |
168
|
5 |
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @return PhotoSize |
172
|
|
|
*/ |
173
|
2 |
|
public function getThumb() |
174
|
|
|
{ |
175
|
2 |
|
return $this->thumb; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @param PhotoSize $thumb |
180
|
|
|
*/ |
181
|
5 |
|
public function setThumb(PhotoSize $thumb) |
182
|
|
|
{ |
183
|
5 |
|
$this->thumb = $thumb; |
184
|
5 |
|
} |
185
|
|
|
} |
186
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.