Completed
Push — master ( 8fbc07...04de59 )
by Armando
03:05 queued 01:27
created

InlineQuery::answer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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