CallbackQuery::subEntities()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace TelegramBot\Entities;
4
5
use TelegramBot\Entity;
6
use TelegramBot\Request;
7
8
/**
9
 * Class CallbackQuery.
10
 *
11
 * @link https://core.telegram.org/bots/api#callbackquery
12
 *
13
 * @method string  getId()                  Unique identifier for this query
14
 * @method User    getFrom()                Sender
15
 * @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
16
 * @method string  getInlineMessageId()     Optional. Identifier of the message sent via the bot in inline mode, that originated the query
17
 * @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.
18
 * @method string  getData()                Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field
19
 * @method string  getGameShortName()       Optional. Short name of a Game to be returned, serves as the unique identifier for the game
20
 */
21
class CallbackQuery extends Entity
22
{
23
24
    /**
25
     * Answer this callback query.
26
     *
27
     * @param array $data
28
     *
29
     * @return Response
30
     */
31
    public function answer(array $data = []): Response
32
    {
33
        return Request::answerCallbackQuery(array_merge([
34
            'callback_query_id' => $this->getId(),
35
        ], $data));
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    protected function subEntities(): array
42
    {
43
        return [
44
            'from' => User::class,
45
            'message' => Message::class,
46
        ];
47
    }
48
49
}
50