callbackQuery   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
c 0
b 0
f 0
dl 0
loc 104
rs 10
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 2
A editKeyboard() 0 2 1
A editText() 0 2 1
A editMedia() 0 2 1
A editCaption() 0 2 1
A answer() 0 2 1
1
<?php
2
3
namespace BPT\types;
4
5
use BPT\telegram\telegram;
6
use stdClass;
7
8
/**
9
 * This object represents an incoming callback query from a callback button in an inline keyboard. If the button
10
 * that originated the query was attached to a message sent by the bot, the field message will be present. If the
11
 * button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be
12
 * present. Exactly one of the fields data or game_short_name will be present.
13
 */
14
class callbackQuery extends types {
0 ignored issues
show
Bug introduced by
The type BPT\types\types was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
    /** Keep all properties which has sub properties */
16
    private const subs = ['from' => 'BPT\types\user', 'message' => 'BPT\types\maybeInaccessibleMessage'];
17
18
    /** Unique identifier for this query */
19
    public string $id;
20
21
    /** Sender */
22
    public user $from;
23
24
    /**
25
     * Optional. Message with the callback button that originated the query. Note that message content and message
26
     * date will not be available if the message is too old
27
     */
28
    public null|maybeInaccessibleMessage $message = null;
29
30
    /** Optional. Identifier of the message sent via the bot in inline mode, that originated the query. */
31
    public null|string $inline_message_id = null;
32
33
    /**
34
     * Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent.
35
     * Useful for high scores in games.
36
     */
37
    public null|string $chat_instance = null;
38
39
    /**
40
     * Optional. Data associated with the callback button. Be aware that the message originated the query can contain
41
     * no callback buttons with this data.
42
     */
43
    public null|string $data = null;
44
45
    /** Optional. Short name of a Game to be returned, serves as the unique identifier for the game */
46
    public null|string $game_short_name = null;
47
48
49
    public function __construct(stdClass|null $object = null) {
50
        if ($object != null) {
51
            parent::__construct($object, self::subs);
52
        }
53
    }
54
55
    /**
56
     * Use this method to send answers to callback queries sent from inline keyboards.
57
     * The answer will be displayed to the user as a notification at the top of the chat screen or as an alert.
58
     * On success, True is returned.
59
     *
60
     * @param null|string $text
61
     * @param null|bool   $show_alert
62
     * @param null|string $url
63
     * @param null|int    $cache_time
64
     * @param bool|null   $answer
65
     *
66
     * @return responseError|bool
67
     */
68
    public function answer (string|null $text = null, bool|null $show_alert = null, string|null $url = null, int|null $cache_time = null, bool $answer = null): responseError|bool {
69
        return telegram::answerCallbackQuery($this->id, $text, $show_alert, $url, $cache_time, answer: $answer);
70
    }
71
72
    /**
73
     * Edit text of the message
74
     *
75
     * @param string    $text
76
     * @param bool|null $answer
77
     *
78
     * @return message|responseError|bool
79
     */
80
    public function editText (string $text, bool $answer = null): message|responseError|bool {
81
        return telegram::editMessageText($text, answer: $answer);
82
    }
83
84
    /**
85
     * Edit caption of the message media
86
     *
87
     * @param string    $text
88
     * @param bool|null $answer
89
     *
90
     * @return message|responseError|bool
91
     */
92
    public function editCaption (string $text = '', bool $answer = null): message|responseError|bool {
93
        return telegram::editMessageCaption(caption: $text, answer: $answer);
94
    }
95
96
    /**
97
     * Edit keyboard of the message
98
     *
99
     * @param inlineKeyboardMarkup|stdClass|array|null $reply_markup
100
     * @param bool|null                                $answer
101
     *
102
     * @return message|responseError|bool
103
     */
104
    public function editKeyboard (inlineKeyboardMarkup|stdClass|array $reply_markup = null, bool $answer = null): message|responseError|bool {
105
        return telegram::editMessageReplyMarkup(reply_markup: $reply_markup, answer: $answer);
106
    }
107
108
    /**
109
     * Edit media of the message
110
     *
111
     * @param inputMedia|array|stdClass $media
112
     * @param bool|null                 $answer
113
     *
114
     * @return message|responseError|bool
115
     */
116
    public function editMedia (inputMedia|array|stdClass $media, bool $answer = null): message|responseError|bool {
117
        return telegram::editMessageMedia($media, answer: $answer);
118
    }
119
}
120