|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This phpFile is auto-generated. |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
declare(strict_types=1); |
|
8
|
|
|
|
|
9
|
|
|
namespace PHPTdGram\Schema; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* A message with a poll. Polls can't be sent to secret chats. Polls can be sent only to a private chat with a bot. |
|
13
|
|
|
*/ |
|
14
|
|
|
class InputMessagePoll extends InputMessageContent |
|
15
|
|
|
{ |
|
16
|
|
|
public const TYPE_NAME = 'inputMessagePoll'; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Poll question, 1-255 characters. |
|
20
|
|
|
*/ |
|
21
|
|
|
protected string $question; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* List of poll answer options, 2-10 strings 1-100 characters each. |
|
25
|
|
|
* |
|
26
|
|
|
* @var string[] |
|
27
|
|
|
*/ |
|
28
|
|
|
protected array $options; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* True, if the poll voters are anonymous. Non-anonymous polls can't be sent or forwarded to channels. |
|
32
|
|
|
*/ |
|
33
|
|
|
protected bool $isAnonymous; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Type of the poll. |
|
37
|
|
|
*/ |
|
38
|
|
|
protected PollType $type; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* True, if the poll needs to be sent already closed; for bots only. |
|
42
|
|
|
*/ |
|
43
|
|
|
protected bool $isClosed; |
|
44
|
|
|
|
|
45
|
|
|
public function __construct(string $question, array $options, bool $isAnonymous, PollType $type, bool $isClosed) |
|
46
|
|
|
{ |
|
47
|
|
|
parent::__construct(); |
|
48
|
|
|
|
|
49
|
|
|
$this->question = $question; |
|
50
|
|
|
$this->options = $options; |
|
51
|
|
|
$this->isAnonymous = $isAnonymous; |
|
52
|
|
|
$this->type = $type; |
|
53
|
|
|
$this->isClosed = $isClosed; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public static function fromArray(array $array): InputMessagePoll |
|
57
|
|
|
{ |
|
58
|
|
|
return new static( |
|
59
|
|
|
$array['question'], |
|
60
|
|
|
$array['options'], |
|
61
|
|
|
$array['is_anonymous'], |
|
62
|
|
|
TdSchemaRegistry::fromArray($array['type']), |
|
63
|
|
|
$array['is_closed'], |
|
64
|
|
|
); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function typeSerialize(): array |
|
68
|
|
|
{ |
|
69
|
|
|
return [ |
|
70
|
|
|
'@type' => static::TYPE_NAME, |
|
71
|
|
|
'question' => $this->question, |
|
72
|
|
|
'options' => $this->options, |
|
73
|
|
|
'is_anonymous' => $this->isAnonymous, |
|
74
|
|
|
'type' => $this->type->typeSerialize(), |
|
75
|
|
|
'is_closed' => $this->isClosed, |
|
76
|
|
|
]; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function getQuestion(): string |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->question; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public function getOptions(): array |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->options; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function getIsAnonymous(): bool |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->isAnonymous; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function getType(): PollType |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->type; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
public function getIsClosed(): bool |
|
100
|
|
|
{ |
|
101
|
|
|
return $this->isClosed; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|