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', '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 |
46
|
|
|
* to be thesame over time and for different bots. |
47
|
|
|
* Can't be used to download or reuse the file. |
48
|
|
|
* |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
protected $fileUniqueId; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Duration of the audio in seconds as defined by sender |
55
|
|
|
* |
56
|
|
|
* @var int |
57
|
|
|
*/ |
58
|
|
|
protected $duration; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Optional. MIME type of the file as defined by sender |
62
|
|
|
* |
63
|
|
|
* @var string |
64
|
|
|
*/ |
65
|
|
|
protected $mimeType; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Optional. File size |
69
|
|
|
* |
70
|
|
|
* @var int |
71
|
|
|
*/ |
72
|
|
|
protected $fileSize; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return string |
76
|
|
|
*/ |
77
|
1 |
|
public function getFileId() |
78
|
|
|
{ |
79
|
1 |
|
return $this->fileId; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @param string $fileId |
84
|
|
|
*/ |
85
|
5 |
|
public function setFileId($fileId) |
86
|
|
|
{ |
87
|
5 |
|
$this->fileId = $fileId; |
88
|
5 |
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return string |
92
|
|
|
*/ |
93
|
|
|
public function getFileUniqueId() |
94
|
|
|
{ |
95
|
|
|
return $this->fileUniqueId; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param string $fileId |
|
|
|
|
100
|
|
|
*/ |
101
|
|
|
public function setFileUniqueId($fileUniqueId) |
102
|
|
|
{ |
103
|
|
|
$this->fileUniqueId = $fileUniqueId; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return int |
108
|
|
|
*/ |
109
|
1 |
|
public function getDuration() |
110
|
|
|
{ |
111
|
1 |
|
return $this->duration; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param int $duration |
116
|
|
|
* |
117
|
|
|
* @throws InvalidArgumentException |
118
|
|
|
*/ |
119
|
6 |
|
public function setDuration($duration) |
120
|
|
|
{ |
121
|
6 |
|
if (is_integer($duration)) { |
122
|
5 |
|
$this->duration = $duration; |
123
|
5 |
|
} else { |
124
|
1 |
|
throw new InvalidArgumentException(); |
125
|
|
|
} |
126
|
5 |
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @return string |
130
|
|
|
*/ |
131
|
1 |
|
public function getMimeType() |
132
|
|
|
{ |
133
|
1 |
|
return $this->mimeType; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param string $mimeType |
138
|
|
|
*/ |
139
|
5 |
|
public function setMimeType($mimeType) |
140
|
|
|
{ |
141
|
5 |
|
$this->mimeType = $mimeType; |
142
|
5 |
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @return int |
146
|
|
|
*/ |
147
|
1 |
|
public function getFileSize() |
148
|
|
|
{ |
149
|
1 |
|
return $this->fileSize; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @param int $fileSize |
154
|
|
|
* |
155
|
|
|
* @throws InvalidArgumentException |
156
|
|
|
*/ |
157
|
6 |
|
public function setFileSize($fileSize) |
158
|
|
|
{ |
159
|
6 |
|
if (is_integer($fileSize)) { |
160
|
5 |
|
$this->fileSize = $fileSize; |
161
|
5 |
|
} else { |
162
|
1 |
|
throw new InvalidArgumentException(); |
163
|
|
|
} |
164
|
5 |
|
} |
165
|
|
|
} |
166
|
|
|
|
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.