GetInlineQueryResults::getUserLocation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
 * Sends an inline query to a bot and returns its results. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires.
13
 */
14
class GetInlineQueryResults extends TdFunction
15
{
16
    public const TYPE_NAME = 'getInlineQueryResults';
17
18
    /**
19
     * The identifier of the target bot.
20
     *
21
     * @var int
22
     */
23
    protected int $botUserId;
24
25
    /**
26
     * Identifier of the chat where the query was sent.
27
     *
28
     * @var int
29
     */
30
    protected int $chatId;
31
32
    /**
33
     * Location of the user, only if needed.
34
     *
35
     * @var Location
36
     */
37
    protected Location $userLocation;
38
39
    /**
40
     * Text of the query.
41
     *
42
     * @var string
43
     */
44
    protected string $query;
45
46
    /**
47
     * Offset of the first entry to return.
48
     *
49
     * @var string
50
     */
51
    protected string $offset;
52
53
    public function __construct(int $botUserId, int $chatId, Location $userLocation, string $query, string $offset)
54
    {
55
        $this->botUserId    = $botUserId;
56
        $this->chatId       = $chatId;
57
        $this->userLocation = $userLocation;
58
        $this->query        = $query;
59
        $this->offset       = $offset;
60
    }
61
62
    public static function fromArray(array $array): GetInlineQueryResults
63
    {
64
        return new static(
65
            $array['bot_user_id'],
66
            $array['chat_id'],
67
            TdSchemaRegistry::fromArray($array['user_location']),
68
            $array['query'],
69
            $array['offset'],
70
        );
71
    }
72
73
    public function typeSerialize(): array
74
    {
75
        return [
76
            '@type'         => static::TYPE_NAME,
77
            'bot_user_id'   => $this->botUserId,
78
            'chat_id'       => $this->chatId,
79
            'user_location' => $this->userLocation->typeSerialize(),
80
            'query'         => $this->query,
81
            'offset'        => $this->offset,
82
        ];
83
    }
84
85
    public function getBotUserId(): int
86
    {
87
        return $this->botUserId;
88
    }
89
90
    public function getChatId(): int
91
    {
92
        return $this->chatId;
93
    }
94
95
    public function getUserLocation(): Location
96
    {
97
        return $this->userLocation;
98
    }
99
100
    public function getQuery(): string
101
    {
102
        return $this->query;
103
    }
104
105
    public function getOffset(): string
106
    {
107
        return $this->offset;
108
    }
109
}
110