CallbackQuery   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 196
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 14
eloc 31
c 2
b 0
f 0
dl 0
loc 196
ccs 30
cts 35
cp 0.8571
rs 10

14 Methods

Rating   Name   Duplication   Size   Complexity  
A getFrom() 0 3 1
A setId() 0 3 1
A getId() 0 3 1
A setData() 0 3 1
A getChatInstance() 0 3 1
A setFrom() 0 3 1
A setGameShortName() 0 3 1
A setChatInstance() 0 3 1
A setMessage() 0 3 1
A getData() 0 3 1
A getInlineMessageId() 0 3 1
A getGameShortName() 0 3 1
A setInlineMessageId() 0 3 1
A getMessage() 0 3 1
1
<?php
2
3
namespace TelegramBot\Api\Types;
4
5
use TelegramBot\Api\BaseType;
6
7
/**
8
 * Class CallbackQuery
9
 * This object represents an incoming callback query from a callback
10
 * button in an inline keyboard.
11
 * If the button that originated the query was attached to a message sent by the bot,
12
 * the field message will be present.
13
 * If the button was attached to a message sent via the bot (in inline mode),
14
 * the field inline_message_id will be present.
15
 * Exactly one of the fields data or game_short_name will be present.
16
 *
17
 * @package TelegramBot\Api\Types
18
 */
19
class CallbackQuery extends BaseType
20
{
21
    /**
22
     * {@inheritdoc}
23
     *
24
     * @var array
25
     */
26
    protected static $requiredParams = ['id', 'from'];
27
28
    /**
29
     * {@inheritdoc}
30
     *
31
     * @var array
32
     */
33
    protected static $map = [
34
        'id' => true,
35
        'from' => User::class,
36
        'message' => Message::class,
37
        'inline_message_id' => true,
38
        'chat_instance' => true,
39
        'data' => true,
40
        'game_short_name' => true
41
    ];
42
43
    /**
44
     * Unique identifier for this query
45
     *
46
     * @var string
47
     */
48
    protected $id;
49
50
    /**
51
     * Sender
52
     *
53
     * @var \TelegramBot\Api\Types\User
54
     */
55
    protected $from;
56
57
    /**
58
     * Optional. Message with the callback button that originated the query.
59
     * Note that message content and message date will not be available
60
     * if the message is too old
61
     *
62
     * @var \TelegramBot\Api\Types\Message|null
63
     */
64
    protected $message;
65
66
    /**
67
     * Optional. Identifier of the message sent via the bot in inline mode,
68
     * that originated the query.
69
     *
70
     * @var string|null
71
     */
72
    protected $inlineMessageId;
73
74
    /**
75
     * Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent.
76
     * Useful for high scores in games.
77
     *
78
     * @var string
79
     */
80
    protected $chatInstance;
81
82
    /**
83
     * Optional. Data associated with the callback button.
84
     * Be aware that a bad client can send arbitrary data in this field.
85
     *
86
     * @var string|null
87
     */
88
    protected $data;
89
90
    /**
91
     * Optional. Short name of a Game to be returned,
92
     * serves as the unique identifier for the game
93
     *
94
     * @var string|null
95
     */
96
    protected $gameShortName;
97
98
    /**
99
     * @return string
100
     */
101
    public function getId()
102 2
    {
103
        return $this->id;
104 2
    }
105
106
    /**
107
     * @param string $id
108
     * @return void
109
     */
110 3
    public function setId($id)
111
    {
112 3
        $this->id = $id;
113 3
    }
114
115
    /**
116
     * @return User
117
     */
118 2
    public function getFrom()
119
    {
120 2
        return $this->from;
121
    }
122
123
    /**
124
     * @param User $from
125
     * @return void
126 3
     */
127
    public function setFrom(User $from)
128 3
    {
129 3
        $this->from = $from;
130
    }
131
132
    /**
133
     * @return Message|null
134
     */
135
    public function getMessage()
136
    {
137
        return $this->message;
138
    }
139
140
    /**
141
     * @param Message $message
142
     * @return void
143
     */
144
    public function setMessage($message)
145
    {
146
        $this->message = $message;
147
    }
148
149
    /**
150 2
     * @return null|string
151
     */
152 2
    public function getInlineMessageId()
153
    {
154
        return $this->inlineMessageId;
155
    }
156
157
    /**
158 3
     * @param string $inlineMessageId
159
     * @return void
160 3
     */
161 3
    public function setInlineMessageId($inlineMessageId)
162
    {
163
        $this->inlineMessageId = $inlineMessageId;
164
    }
165
166 2
    /**
167
     * @return string
168 2
     */
169
    public function getChatInstance()
170
    {
171
        return $this->chatInstance;
172
    }
173
174 3
    /**
175
     * @param string $chatInstance
176 3
     * @return void
177 3
     */
178
    public function setChatInstance($chatInstance)
179
    {
180
        $this->chatInstance = $chatInstance;
181
    }
182 2
183
    /**
184 2
     * @return null|string
185
     */
186
    public function getData()
187
    {
188
        return $this->data;
189
    }
190 3
191
    /**
192 3
     * @param string $data
193 3
     * @return void
194
     */
195
    public function setData($data)
196
    {
197
        $this->data = $data;
198 2
    }
199
200 2
    /**
201
     * @return null|string
202
     */
203
    public function getGameShortName()
204
    {
205
        return $this->gameShortName;
206 3
    }
207
208 3
    /**
209 3
     * @param string $gameShortName
210
     * @return void
211
     */
212
    public function setGameShortName($gameShortName)
213
    {
214
        $this->gameShortName = $gameShortName;
215
    }
216
}
217