|
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 Voice |
|
11
|
|
|
* This object represents a voice note. |
|
12
|
|
|
* |
|
13
|
|
|
* @package TelegramBot\Api\Types |
|
14
|
|
|
*/ |
|
15
|
|
|
class Voice extends BaseType implements TypeInterface |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* {@inheritdoc} |
|
19
|
|
|
* |
|
20
|
|
|
* @var array |
|
21
|
|
|
*/ |
|
22
|
|
|
static protected $requiredParams = ['file_id', 'file_unique_id', 'duration']; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* {@inheritdoc} |
|
26
|
|
|
* |
|
27
|
|
|
* @var array |
|
28
|
|
|
*/ |
|
29
|
|
|
static protected $map = [ |
|
30
|
|
|
'file_id' => true, |
|
31
|
|
|
'file_unique_id' => true, |
|
32
|
|
|
'duration' => true, |
|
33
|
|
|
'mime_type' => true, |
|
34
|
|
|
'file_size' => true, |
|
35
|
|
|
]; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Identifier for this file, which can be used to download or reuse the file |
|
39
|
|
|
* |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $fileId; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be |
|
46
|
|
|
* used to download or reuse the file. |
|
47
|
|
|
* |
|
48
|
|
|
* @var string |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $fileUniqueId; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Duration of the audio in seconds as defined by sender |
|
54
|
|
|
* |
|
55
|
|
|
* @var int |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $duration; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Optional. MIME type of the file as defined by sender |
|
61
|
|
|
* |
|
62
|
|
|
* @var string |
|
63
|
|
|
*/ |
|
64
|
|
|
protected $mimeType; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Optional. File size |
|
68
|
|
|
* |
|
69
|
|
|
* @var int |
|
70
|
|
|
*/ |
|
71
|
|
|
protected $fileSize; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return string |
|
75
|
|
|
*/ |
|
76
|
1 |
|
public function getFileId() |
|
77
|
|
|
{ |
|
78
|
1 |
|
return $this->fileId; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @param string $fileId |
|
83
|
|
|
*/ |
|
84
|
5 |
|
public function setFileId($fileId) |
|
85
|
|
|
{ |
|
86
|
5 |
|
$this->fileId = $fileId; |
|
87
|
5 |
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @return string |
|
91
|
|
|
*/ |
|
92
|
1 |
|
public function getFileUniqueId() |
|
93
|
|
|
{ |
|
94
|
1 |
|
return $this->fileUniqueId; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @param string $fileUniqueId |
|
99
|
|
|
*/ |
|
100
|
5 |
|
public function setFileUniqueId($fileUniqueId) |
|
101
|
|
|
{ |
|
102
|
5 |
|
$this->fileUniqueId = $fileUniqueId; |
|
103
|
5 |
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @return int |
|
107
|
|
|
*/ |
|
108
|
1 |
|
public function getDuration() |
|
109
|
|
|
{ |
|
110
|
1 |
|
return $this->duration; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @param int $duration |
|
115
|
|
|
* |
|
116
|
|
|
* @throws InvalidArgumentException |
|
117
|
|
|
*/ |
|
118
|
6 |
|
public function setDuration($duration) |
|
119
|
|
|
{ |
|
120
|
6 |
|
if (is_integer($duration)) { |
|
121
|
5 |
|
$this->duration = $duration; |
|
122
|
5 |
|
} else { |
|
123
|
1 |
|
throw new InvalidArgumentException(); |
|
124
|
|
|
} |
|
125
|
5 |
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* @return string |
|
129
|
|
|
*/ |
|
130
|
1 |
|
public function getMimeType() |
|
131
|
|
|
{ |
|
132
|
1 |
|
return $this->mimeType; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @param string $mimeType |
|
137
|
|
|
*/ |
|
138
|
5 |
|
public function setMimeType($mimeType) |
|
139
|
|
|
{ |
|
140
|
5 |
|
$this->mimeType = $mimeType; |
|
141
|
5 |
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* @return int |
|
145
|
|
|
*/ |
|
146
|
1 |
|
public function getFileSize() |
|
147
|
|
|
{ |
|
148
|
1 |
|
return $this->fileSize; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* @param int $fileSize |
|
153
|
|
|
* |
|
154
|
|
|
* @throws InvalidArgumentException |
|
155
|
|
|
*/ |
|
156
|
6 |
|
public function setFileSize($fileSize) |
|
157
|
|
|
{ |
|
158
|
6 |
|
if (is_integer($fileSize)) { |
|
159
|
5 |
|
$this->fileSize = $fileSize; |
|
160
|
5 |
|
} else { |
|
161
|
1 |
|
throw new InvalidArgumentException(); |
|
162
|
|
|
} |
|
163
|
5 |
|
} |
|
164
|
|
|
} |
|
165
|
|
|
|