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 Poll |
11
|
|
|
* This object contains information about a poll. |
12
|
|
|
* |
13
|
|
|
* @package TelegramBot\Api\Types |
14
|
|
|
*/ |
15
|
|
|
class Poll extends BaseType implements TypeInterface |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* {@inheritdoc} |
19
|
|
|
* |
20
|
|
|
* @var array |
21
|
|
|
*/ |
22
|
|
|
protected static $requiredParams = [ |
23
|
|
|
'id', |
24
|
|
|
'question', |
25
|
|
|
'options', |
26
|
|
|
'total_voter_count', |
27
|
|
|
'is_closed', |
28
|
|
|
'is_anonymous', |
29
|
|
|
'type', |
30
|
|
|
'allows_multiple_answers', |
31
|
|
|
]; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* {@inheritdoc} |
35
|
|
|
* |
36
|
|
|
* @var array |
37
|
|
|
*/ |
38
|
|
|
protected static $map = [ |
39
|
|
|
'id' => true, |
40
|
|
|
'question' => true, |
41
|
|
|
'options' => ArrayOfPollOption::class, |
42
|
|
|
'total_voter_count' => true, |
43
|
|
|
'is_closed' => true, |
44
|
|
|
'is_anonymous' => true, |
45
|
|
|
'type' => true, |
46
|
|
|
'allows_multiple_answers' => true, |
47
|
|
|
'correct_option_id' => true, |
48
|
|
|
]; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Unique poll identifier |
52
|
|
|
* |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
protected $id; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Poll question, 1-255 characters |
59
|
|
|
* |
60
|
|
|
* @var string |
61
|
|
|
*/ |
62
|
|
|
protected $question; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* List of poll options |
66
|
|
|
* Array of \TelegramBot\Api\Types\PollOption |
67
|
|
|
* |
68
|
|
|
* @var array |
69
|
|
|
*/ |
70
|
|
|
protected $options; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Total number of users that voted in the poll |
74
|
|
|
* |
75
|
|
|
* @var int |
76
|
|
|
*/ |
77
|
|
|
protected $totalVoterCount; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* True, if the poll is closed |
81
|
|
|
* |
82
|
|
|
* @var boolean |
83
|
|
|
*/ |
84
|
|
|
protected $isClosed; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* True, if the poll is anonymous |
88
|
|
|
* |
89
|
|
|
* @var bool |
90
|
|
|
*/ |
91
|
|
|
protected $isAnonymous; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Poll type, currently can be “regular” or “quiz” |
95
|
|
|
* |
96
|
|
|
* @var string |
97
|
|
|
*/ |
98
|
|
|
protected $type; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* True, if the poll allows multiple answers |
102
|
|
|
* |
103
|
|
|
* @var bool |
104
|
|
|
*/ |
105
|
|
|
protected $allowsMultipleAnswers; |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Optional. 0-based identifier of the correct answer option. |
109
|
|
|
* Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) |
110
|
|
|
* by the bot or to the private chat with the bot. |
111
|
|
|
* |
112
|
|
|
* @var int |
113
|
|
|
*/ |
114
|
|
|
protected $correctOptionId; |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return string |
118
|
|
|
*/ |
119
|
1 |
|
public function getId() |
120
|
|
|
{ |
121
|
1 |
|
return $this->id; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @param string $id |
126
|
|
|
*/ |
127
|
2 |
|
public function setId($id) |
128
|
|
|
{ |
129
|
2 |
|
$this->id = $id; |
130
|
2 |
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return string |
134
|
|
|
*/ |
135
|
1 |
|
public function getQuestion() |
136
|
|
|
{ |
137
|
1 |
|
return $this->question; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @param string $question |
142
|
|
|
*/ |
143
|
2 |
|
public function setQuestion($question) |
144
|
|
|
{ |
145
|
2 |
|
$this->question = $question; |
146
|
2 |
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @return array |
150
|
|
|
*/ |
151
|
1 |
|
public function getOptions() |
152
|
|
|
{ |
153
|
1 |
|
return $this->options; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @param array $options |
158
|
|
|
*/ |
159
|
2 |
|
public function setOptions($options) |
160
|
|
|
{ |
161
|
2 |
|
$this->options = $options; |
162
|
2 |
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @return int |
166
|
|
|
*/ |
167
|
|
|
public function getTotalVoterCount() |
168
|
|
|
{ |
169
|
|
|
return $this->totalVoterCount; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @param int $totalVoterCount |
174
|
|
|
*/ |
175
|
2 |
|
public function setTotalVoterCount($totalVoterCount) |
176
|
|
|
{ |
177
|
2 |
|
$this->totalVoterCount = $totalVoterCount; |
178
|
2 |
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @return bool |
182
|
|
|
*/ |
183
|
1 |
|
public function isClosed() |
184
|
|
|
{ |
185
|
1 |
|
return $this->isClosed; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @param bool $isClosed |
190
|
|
|
*/ |
191
|
2 |
|
public function setIsClosed($isClosed) |
192
|
|
|
{ |
193
|
2 |
|
$this->isClosed = $isClosed; |
194
|
2 |
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @return bool |
198
|
|
|
*/ |
199
|
1 |
|
public function isAnonymous() |
200
|
|
|
{ |
201
|
1 |
|
return $this->isAnonymous; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @param bool $isAnonymous |
206
|
|
|
*/ |
207
|
2 |
|
public function setIsAnonymous($isAnonymous) |
208
|
|
|
{ |
209
|
2 |
|
$this->isAnonymous = $isAnonymous; |
210
|
2 |
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @return string |
214
|
|
|
*/ |
215
|
2 |
|
public function getType() |
216
|
|
|
{ |
217
|
2 |
|
return $this->type; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @param string $type |
222
|
|
|
*/ |
223
|
2 |
|
public function setType($type) |
224
|
|
|
{ |
225
|
2 |
|
$this->type = $type; |
226
|
2 |
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @return bool |
230
|
|
|
*/ |
231
|
1 |
|
public function isAllowsMultipleAnswers() |
232
|
|
|
{ |
233
|
1 |
|
return $this->allowsMultipleAnswers; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @param bool $allowsMultipleAnswers |
238
|
|
|
*/ |
239
|
2 |
|
public function setAllowsMultipleAnswers($allowsMultipleAnswers) |
240
|
|
|
{ |
241
|
2 |
|
$this->allowsMultipleAnswers = $allowsMultipleAnswers; |
242
|
2 |
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @return int |
246
|
|
|
*/ |
247
|
1 |
|
public function getCorrectOptionId() |
248
|
|
|
{ |
249
|
1 |
|
return $this->correctOptionId; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @param int $correctOptionId |
254
|
|
|
*/ |
255
|
2 |
|
public function setCorrectOptionId($correctOptionId) |
256
|
|
|
{ |
257
|
2 |
|
$this->correctOptionId = $correctOptionId; |
258
|
2 |
|
} |
259
|
|
|
} |
260
|
|
|
|