Completed
Push — master ( 1ab7f6...5e4939 )
by Camilo
01:36
created

PollAnswer::mapSubObjects()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 8
ccs 0
cts 4
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace unreal4u\TelegramAPI\Telegram\Types;
6
7
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
8
9
/**
10
 * This object represents an answer of a user in a non-anonymous poll.
11
 *
12
 * Objects defined as-is June 2020, Bot API v4.9
13
 *
14
 * @see https://core.telegram.org/bots/api#pollanswer
15
 */
16
class PollAnswer extends TelegramTypes
17
{
18
    /**
19
     * Unique poll identifier
20
     * @var string
21
     */
22
    public $poll_id;
23
24
    /**
25
     * The user, who changed the answer to the poll
26
     * @var User
27
     */
28
    public $user;
29
30
    /**
31
     * 0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.
32
     * @var int[]
33
     */
34
    public $option_ids = [];
35
36
    public function mapSubObjects(string $key, array $data): TelegramTypes
37
    {
38
        switch ($key) {
39
            case 'user':
40
                return new User($data, $this->logger);
41
        }
42
        return parent::mapSubObjects($key, $data);
43
    }
44
}
45