CallbackqueryCommand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 40
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 16 1
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\Commands\SystemCommands;
12
13
use Longman\TelegramBot\Commands\SystemCommand;
14
use Longman\TelegramBot\Request;
15
16
/**
17
 * Callback query command
18
 */
19
class CallbackqueryCommand extends SystemCommand
20
{
21
    /**
22
     * @var string
23
     */
24
    protected $name = 'callbackquery';
25
26
    /**
27
     * @var string
28
     */
29
    protected $description = 'Reply to callback query';
30
31
    /**
32
     * @var string
33
     */
34
    protected $version = '1.1.0';
35
36
    /**
37
     * Command execute method
38
     *
39
     * @return mixed
40
     * @throws \Longman\TelegramBot\Exception\TelegramException
41
     */
42
    public function execute()
43
    {
44
        $update            = $this->getUpdate();
45
        $callback_query    = $update->getCallbackQuery();
46
        $callback_query_id = $callback_query->getId();
47
        $callback_data     = $callback_query->getData();
48
49
        $data = [
50
            'callback_query_id' => $callback_query_id,
51
            'text'              => 'Hello World!',
52
            'show_alert'        => $callback_data === 'thumb up',
53
            'cache_time'        => 5,
54
        ];
55
56
        return Request::answerCallbackQuery($data);
57
    }
58
}
59