InlineQuery   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 27
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A answer() 0 6 1
A subEntities() 0 5 1
1
<?php
2
3
namespace TelegramBot\Entities;
4
5
use TelegramBot\Entities\InlineQuery\InlineQueryResult;
6
use TelegramBot\Entity;
7
use TelegramBot\Request;
8
9
/**
10
 * Class InlineQuery
11
 *
12
 * @link https://core.telegram.org/bots/api#inlinequery
13
 *
14
 * @method string   getId()         Unique identifier for this query
15
 * @method User     getFrom()       Sender
16
 * @method Location getLocation()   Optional. Sender location, only for bots that request user location
17
 * @method string   getQuery()      Text of the query (up to 512 characters)
18
 * @method string   getOffset()     Offset of the results to be returned, can be controlled by the bot
19
 * @method string   getChatType()   Optional. Type of the chat, from which the inline query was sent. Can be either “sender” for a private chat with the inline query sender, “private”, “group”, “supergroup”, or “channel”. The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chat
20
 */
21
class InlineQuery extends Entity
22
{
23
24
    /**
25
     * Answer this inline query with the passed results.
26
     *
27
     * @param InlineQueryResult[] $results
28
     * @param array $data
29
     *
30
     * @return Response
31
     */
32
    public function answer(array $results, array $data = []): Response
33
    {
34
        return Request::answerInlineQuery(array_merge([
35
            'inline_query_id' => $this->getId(),
36
            'results' => $results,
37
        ], $data));
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    protected function subEntities(): array
44
    {
45
        return [
46
            'from' => User::class,
47
            'location' => Location::class,
48
        ];
49
    }
50
51
}
52