InlineQuery   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 27
ccs 0
cts 10
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A subEntities() 0 5 1
A answer() 0 6 1
1
<?php
2
3
/**
4
 * This file is part of the TelegramBot package.
5
 *
6
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Longman\TelegramBot\Entities;
13
14
use Longman\TelegramBot\Entities\InlineQuery\InlineQueryResult;
15
use Longman\TelegramBot\Request;
16
17
/**
18
 * Class InlineQuery
19
 *
20
 * @link https://core.telegram.org/bots/api#inlinequery
21
 *
22
 * @method string   getId()       Unique identifier for this query
23
 * @method User     getFrom()     Sender
24
 * @method Location getLocation() Optional. Sender location, only for bots that request user location
25
 * @method string   getQuery()    Text of the query (up to 512 characters)
26
 * @method string   getOffset()   Offset of the results to be returned, can be controlled by the bot
27
 * @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
28
 */
29
class InlineQuery extends Entity
30
{
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function subEntities(): array
35
    {
36
        return [
37
            'from'     => User::class,
38
            'location' => Location::class,
39
        ];
40
    }
41
42
    /**
43
     * Answer this inline query with the passed results.
44
     *
45
     * @param InlineQueryResult[] $results
46
     * @param array               $data
47
     *
48
     * @return ServerResponse
49
     */
50
    public function answer(array $results, array $data = []): ServerResponse
51
    {
52
        return Request::answerInlineQuery(array_merge([
53
            'inline_query_id' => $this->getId(),
54
            'results'         => $results,
55
        ], $data));
56
    }
57
}
58