Completed
Push — master ( e9be36...9488e8 )
by Camilo
04:57
created

ChosenResult::mapSubObjects()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
ccs 3
cts 3
cp 1
rs 9.4285
cc 3
eloc 7
nc 3
nop 2
crap 3
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace unreal4u\TelegramAPI\Telegram\Types\Inline;
6
7
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
8
use unreal4u\TelegramAPI\Telegram\Types\User;
9
use unreal4u\TelegramAPI\Telegram\Types\Location;
10
11
/**
12
 * This object represents a result of an inline query that was chosen by the user and sent to their chat partner.
13
 *
14
 * Objects defined as-is july 2016
15
 *
16
 * @see https://core.telegram.org/bots/api#choseninlineresult
17
 */
18
class ChosenResult extends TelegramTypes
19
{
20
    /**
21
     * The unique identifier for the result that was chosen
22
     * @var string
23
     */
24
    public $result_id = '';
25
26
    /**
27
     * The user that chose the result
28
     * @var User
29
     */
30
    public $from = null;
31
32
    /**
33
     * Optional. Sender location, only for bots that require user location
34
     * @var Location
35
     */
36
    public $location = null;
37
38
    /**
39
     * Optional. Identifier of the sent inline message. Available only if there is an inline keyboard attached to the
40
     * message. Will be also received in callback queries and can be used to edit the message.
41
     * @var string
42
     */
43
    public $inline_message_id = '';
44
45
    /**
46
     * Text of the query
47
     * @var string
48
     */
49
    public $query = '';
50
51 1
    protected function mapSubObjects(string $key, array $data): TelegramTypes
52
    {
53
        switch ($key) {
54 1
            case 'from':
55 1
                return new User($data, $this->logger);
56
            case 'location':
57
                return new Location($data, $this->logger);
58
        }
59
60
        return parent::mapSubObjects($key, $data);
61
    }
62
}
63