InlineQuery::subEntities()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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
 */
28
class InlineQuery extends Entity
29
{
30
    /**
31
     * {@inheritdoc}
32
     */
33
    protected function subEntities(): array
34
    {
35
        return [
36
            'from'     => User::class,
37
            'location' => Location::class,
38
        ];
39
    }
40
41
    /**
42
     * Answer this inline query with the passed results.
43
     *
44
     * @param InlineQueryResult[] $results
45
     * @param array               $data
46
     *
47
     * @return ServerResponse
48
     */
49
    public function answer(array $results, array $data = []): ServerResponse
50
    {
51
        return Request::answerInlineQuery(array_merge([
52
            'inline_query_id' => $this->getId(),
53
            'results'         => $results,
54
        ], $data));
55
    }
56
}
57