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

CallbackQuery::answer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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