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 Video |
11
|
|
|
* This object represents a video file. |
12
|
|
|
* |
13
|
|
|
* @package TelegramBot\Api\Types |
14
|
|
|
*/ |
15
|
|
|
class Video extends BaseType implements TypeInterface |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* {@inheritdoc} |
19
|
|
|
* |
20
|
|
|
* @var array |
21
|
|
|
*/ |
22
|
|
|
protected static $requiredParams = ['file_id', 'file_unique_id', 'width', 'height', 'duration']; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
* |
27
|
|
|
* @var array |
28
|
|
|
*/ |
29
|
|
|
protected static $map = [ |
30
|
|
|
'file_id' => true, |
31
|
|
|
'file_unique_id' => true, |
32
|
|
|
'width' => true, |
33
|
|
|
'height' => true, |
34
|
|
|
'duration' => true, |
35
|
|
|
'thumbnail' => PhotoSize::class, |
36
|
|
|
'mime_type' => true, |
37
|
|
|
'file_size' => true |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Unique identifier for this file |
42
|
|
|
* |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
protected $fileId; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Video width as defined by sender |
49
|
|
|
* |
50
|
|
|
* @var int |
51
|
|
|
*/ |
52
|
|
|
protected $width; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Video height as defined by sender |
56
|
|
|
* |
57
|
|
|
* @var int |
58
|
|
|
*/ |
59
|
|
|
protected $height; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Duration of the video in seconds as defined by sender |
63
|
|
|
* |
64
|
|
|
* @var int |
65
|
|
|
*/ |
66
|
|
|
protected $duration; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Video thumbnail |
70
|
|
|
* |
71
|
|
|
* @var PhotoSize|null |
72
|
|
|
*/ |
73
|
|
|
protected $thumbnail; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Optional. Mime type of a file as defined by sender |
77
|
|
|
* |
78
|
|
|
* @var string|null |
79
|
|
|
*/ |
80
|
|
|
protected $mimeType; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Optional. File size |
84
|
|
|
* |
85
|
|
|
* @var int|null |
86
|
|
|
*/ |
87
|
|
|
protected $fileSize; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* 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. |
91
|
|
|
* |
92
|
|
|
* @var string |
93
|
|
|
*/ |
94
|
|
|
protected $fileUniqueId; |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return int |
98
|
|
|
*/ |
99
|
|
|
public function getDuration() |
100
|
1 |
|
{ |
101
|
|
|
return $this->duration; |
102
|
1 |
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param mixed $duration |
106
|
|
|
* |
107
|
|
|
* @throws InvalidArgumentException |
108
|
|
|
* |
109
|
|
|
* @return void |
110
|
6 |
|
*/ |
111
|
|
|
public function setDuration($duration) |
112
|
6 |
|
{ |
113
|
5 |
|
if (is_integer($duration)) { |
114
|
5 |
|
$this->duration = $duration; |
115
|
1 |
|
} else { |
116
|
|
|
throw new InvalidArgumentException(); |
117
|
5 |
|
} |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return string |
122
|
1 |
|
*/ |
123
|
|
|
public function getFileId() |
124
|
1 |
|
{ |
125
|
|
|
return $this->fileId; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param string $fileId |
130
|
5 |
|
* |
131
|
|
|
* @return void |
132
|
5 |
|
*/ |
133
|
5 |
|
public function setFileId($fileId) |
134
|
|
|
{ |
135
|
|
|
$this->fileId = $fileId; |
136
|
|
|
} |
137
|
|
|
|
138
|
1 |
|
/** |
139
|
|
|
* @return int|null |
140
|
1 |
|
*/ |
141
|
|
|
public function getFileSize() |
142
|
|
|
{ |
143
|
|
|
return $this->fileSize; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @param mixed $fileSize |
148
|
6 |
|
* |
149
|
|
|
* @throws InvalidArgumentException |
150
|
6 |
|
* |
151
|
5 |
|
* @return void |
152
|
5 |
|
*/ |
153
|
1 |
|
public function setFileSize($fileSize) |
154
|
|
|
{ |
155
|
5 |
|
if (is_integer($fileSize)) { |
156
|
|
|
$this->fileSize = $fileSize; |
157
|
|
|
} else { |
158
|
|
|
throw new InvalidArgumentException(); |
159
|
|
|
} |
160
|
1 |
|
} |
161
|
|
|
|
162
|
1 |
|
/** |
163
|
|
|
* @return int |
164
|
|
|
*/ |
165
|
|
|
public function getHeight() |
166
|
|
|
{ |
167
|
|
|
return $this->height; |
168
|
|
|
} |
169
|
|
|
|
170
|
6 |
|
/** |
171
|
|
|
* @param mixed $height |
172
|
6 |
|
* |
173
|
5 |
|
* @throws InvalidArgumentException |
174
|
5 |
|
* |
175
|
1 |
|
* @return void |
176
|
|
|
*/ |
177
|
5 |
|
public function setHeight($height) |
178
|
|
|
{ |
179
|
|
|
if (is_integer($height)) { |
180
|
|
|
$this->height = $height; |
181
|
|
|
} else { |
182
|
1 |
|
throw new InvalidArgumentException(); |
183
|
|
|
} |
184
|
1 |
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @return null|string |
188
|
|
|
*/ |
189
|
|
|
public function getMimeType() |
190
|
5 |
|
{ |
191
|
|
|
return $this->mimeType; |
192
|
5 |
|
} |
193
|
5 |
|
|
194
|
|
|
/** |
195
|
|
|
* @param string $mimeType |
196
|
|
|
* |
197
|
|
|
* @return void |
198
|
2 |
|
*/ |
199
|
|
|
public function setMimeType($mimeType) |
200
|
2 |
|
{ |
201
|
|
|
$this->mimeType = $mimeType; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @return PhotoSize|null |
206
|
5 |
|
*/ |
207
|
|
|
public function getThumbnail() |
208
|
5 |
|
{ |
209
|
5 |
|
return $this->thumbnail; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @param PhotoSize|null $thumbnail |
214
|
1 |
|
* |
215
|
|
|
* @return void |
216
|
1 |
|
*/ |
217
|
|
|
public function setThumbnail($thumbnail) |
218
|
|
|
{ |
219
|
|
|
$this->thumbnail = $thumbnail; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* @deprecated use getThumbnail method |
224
|
6 |
|
* |
225
|
|
|
* @return PhotoSize|null |
226
|
6 |
|
*/ |
227
|
5 |
|
public function getThumb() |
228
|
5 |
|
{ |
229
|
1 |
|
return $this->getThumbnail(); |
230
|
|
|
} |
231
|
5 |
|
|
232
|
|
|
/** |
233
|
|
|
* @deprecated use setThumbnail method |
234
|
|
|
* |
235
|
|
|
* @param PhotoSize|null $thumb |
236
|
|
|
* |
237
|
|
|
* @return void |
238
|
|
|
*/ |
239
|
|
|
public function setThumb($thumb) |
240
|
|
|
{ |
241
|
|
|
$this->setThumbnail($thumb); |
242
|
|
|
} |
243
|
|
|
|
244
|
3 |
|
/** |
245
|
|
|
* @return int |
246
|
3 |
|
*/ |
247
|
3 |
|
public function getWidth() |
248
|
|
|
{ |
249
|
|
|
return $this->width; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @param mixed $width |
254
|
|
|
* |
255
|
|
|
* @throws InvalidArgumentException |
256
|
|
|
* |
257
|
|
|
* @return void |
258
|
|
|
*/ |
259
|
|
|
public function setWidth($width) |
260
|
|
|
{ |
261
|
|
|
if (is_integer($width)) { |
262
|
|
|
$this->width = $width; |
263
|
|
|
} else { |
264
|
|
|
throw new InvalidArgumentException(); |
265
|
|
|
} |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @return string |
270
|
|
|
*/ |
271
|
|
|
public function getFileUniqueId() |
272
|
|
|
{ |
273
|
|
|
return $this->fileUniqueId; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* @param string $fileUniqueId |
278
|
|
|
* |
279
|
|
|
* @return void |
280
|
|
|
*/ |
281
|
|
|
public function setFileUniqueId($fileUniqueId) |
282
|
|
|
{ |
283
|
|
|
$this->fileUniqueId = $fileUniqueId; |
284
|
|
|
} |
285
|
|
|
} |
286
|
|
|
|