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
|
|
View Code Duplication |
class VideoNote extends BaseType implements TypeInterface |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* {@inheritdoc} |
19
|
|
|
* |
20
|
|
|
* @var array |
21
|
|
|
*/ |
22
|
|
|
static protected $requiredParams = ['file_id', 'length', 'duration']; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
* |
27
|
|
|
* @var array |
28
|
|
|
*/ |
29
|
|
|
static protected $map = [ |
30
|
|
|
'file_id' => true, |
31
|
|
|
'length' => true, |
32
|
|
|
'duration' => true, |
33
|
|
|
'thumb' => PhotoSize::class, |
34
|
|
|
'file_size' => true |
35
|
|
|
]; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Unique identifier for this file |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
protected $fileId; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Duration of the video note in seconds as defined by sender |
46
|
|
|
* |
47
|
|
|
* @var int |
48
|
|
|
*/ |
49
|
|
|
protected $duration; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Value of video width and height (diameter of the video message) as defined by sender |
53
|
|
|
* |
54
|
|
|
* @var int |
55
|
|
|
*/ |
56
|
|
|
protected $length; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Video Note thumbnail |
60
|
|
|
* |
61
|
|
|
* @var PhotoSize |
62
|
|
|
*/ |
63
|
|
|
protected $thumb; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Optional. File size |
67
|
|
|
* |
68
|
|
|
* @var int |
69
|
|
|
*/ |
70
|
|
|
protected $fileSize; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return int |
74
|
|
|
*/ |
75
|
1 |
|
public function getDuration() |
76
|
|
|
{ |
77
|
1 |
|
return $this->duration; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param int $duration |
82
|
|
|
* |
83
|
|
|
* @throws InvalidArgumentException |
84
|
|
|
*/ |
85
|
4 |
|
public function setDuration($duration) |
86
|
|
|
{ |
87
|
4 |
|
if (is_integer($duration)) { |
88
|
3 |
|
$this->duration = $duration; |
89
|
3 |
|
} else { |
90
|
1 |
|
throw new InvalidArgumentException('VideoNote duration does not contain integer values'); |
91
|
|
|
} |
92
|
3 |
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
1 |
|
public function getFileId() |
98
|
|
|
{ |
99
|
1 |
|
return $this->fileId; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param string $fileId |
104
|
|
|
*/ |
105
|
3 |
|
public function setFileId($fileId) |
106
|
|
|
{ |
107
|
3 |
|
$this->fileId = $fileId; |
108
|
3 |
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @return int |
112
|
|
|
*/ |
113
|
1 |
|
public function getFileSize() |
114
|
|
|
{ |
115
|
1 |
|
return $this->fileSize; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param int $fileSize |
120
|
|
|
* |
121
|
|
|
* @throws InvalidArgumentException |
122
|
|
|
*/ |
123
|
4 |
|
public function setFileSize($fileSize) |
124
|
|
|
{ |
125
|
4 |
|
if (is_integer($fileSize)) { |
126
|
3 |
|
$this->fileSize = $fileSize; |
127
|
3 |
|
} else { |
128
|
1 |
|
throw new InvalidArgumentException('VideoNote file_size does not contain integer values'); |
129
|
|
|
} |
130
|
3 |
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return int |
134
|
|
|
*/ |
135
|
|
|
public function getLength() |
136
|
|
|
{ |
137
|
|
|
return $this->length; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @param int $length |
142
|
|
|
* |
143
|
|
|
* @throws InvalidArgumentException |
144
|
|
|
*/ |
145
|
2 |
|
public function setLength($length) |
146
|
|
|
{ |
147
|
2 |
|
if (is_integer($length)) { |
148
|
1 |
|
$this->length = $length; |
149
|
1 |
|
} else { |
150
|
1 |
|
throw new InvalidArgumentException('VideoNote length does not contain integer values'); |
151
|
|
|
} |
152
|
1 |
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @return PhotoSize |
156
|
|
|
*/ |
157
|
2 |
|
public function getThumb() |
158
|
|
|
{ |
159
|
2 |
|
return $this->thumb; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @param PhotoSize $thumb |
164
|
|
|
*/ |
165
|
3 |
|
public function setThumb(PhotoSize $thumb) |
166
|
|
|
{ |
167
|
3 |
|
$this->thumb = $thumb; |
168
|
3 |
|
} |
169
|
|
|
|
170
|
|
|
} |
171
|
|
|
|