SetPollAnswer   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 64
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A fromArray() 0 6 1
A getMessageId() 0 3 1
A getOptionIds() 0 3 1
A typeSerialize() 0 7 1
A getChatId() 0 3 1
A __construct() 0 5 1
1
<?php
2
3
/**
4
 * This phpFile is auto-generated.
5
 */
6
7
declare(strict_types=1);
8
9
namespace AurimasNiekis\TdLibSchema;
10
11
/**
12
 * Changes the user answer to a poll. A poll in quiz mode can be answered only once.
13
 */
14
class SetPollAnswer extends TdFunction
15
{
16
    public const TYPE_NAME = 'setPollAnswer';
17
18
    /**
19
     * Identifier of the chat to which the poll belongs.
20
     *
21
     * @var int
22
     */
23
    protected int $chatId;
24
25
    /**
26
     * Identifier of the message containing the poll.
27
     *
28
     * @var int
29
     */
30
    protected int $messageId;
31
32
    /**
33
     * 0-based identifiers of answer options, chosen by the user. User can choose more than 1 answer option only is the poll allows multiple answers.
34
     *
35
     * @var int[]
36
     */
37
    protected array $optionIds;
38
39
    public function __construct(int $chatId, int $messageId, array $optionIds)
40
    {
41
        $this->chatId    = $chatId;
42
        $this->messageId = $messageId;
43
        $this->optionIds = $optionIds;
44
    }
45
46
    public static function fromArray(array $array): SetPollAnswer
47
    {
48
        return new static(
49
            $array['chat_id'],
50
            $array['message_id'],
51
            $array['option_ids'],
52
        );
53
    }
54
55
    public function typeSerialize(): array
56
    {
57
        return [
58
            '@type'      => static::TYPE_NAME,
59
            'chat_id'    => $this->chatId,
60
            'message_id' => $this->messageId,
61
            'option_ids' => $this->optionIds,
62
        ];
63
    }
64
65
    public function getChatId(): int
66
    {
67
        return $this->chatId;
68
    }
69
70
    public function getMessageId(): int
71
    {
72
        return $this->messageId;
73
    }
74
75
    public function getOptionIds(): array
76
    {
77
        return $this->optionIds;
78
    }
79
}
80