CallbackQuery::answer()   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 1
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\Request;
15
16
/**
17
 * Class CallbackQuery.
18
 *
19
 * @link https://core.telegram.org/bots/api#callbackquery
20
 *
21
 * @method string  getId()              Unique identifier for this query
22
 * @method User    getFrom()            Sender
23
 * @method Message getMessage()         Optional. Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old
24
 * @method string  getInlineMessageId() Optional. Identifier of the message sent via the bot in inline mode, that originated the query
25
 * @method string  getChatInstance()    Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games.
26
 * @method string  getData()            Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field
27
 * @method string  getGameShortName()   Optional. Short name of a Game to be returned, serves as the unique identifier for the game
28
 */
29
class CallbackQuery extends Entity
30
{
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function subEntities(): array
35
    {
36
        return [
37
            'from'    => User::class,
38
            'message' => Message::class,
39
        ];
40
    }
41
42
    /**
43
     * Answer this callback query.
44
     *
45
     * @param array $data
46
     *
47
     * @return ServerResponse
48
     */
49
    public function answer(array $data = []): ServerResponse
50
    {
51
        return Request::answerCallbackQuery(array_merge([
52
            'callback_query_id' => $this->getId(),
53
        ], $data));
54
    }
55
}
56