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