1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the PhpBotFramework. |
5
|
|
|
* |
6
|
|
|
* PhpBotFramework is free software: you can redistribute it and/or modify |
7
|
|
|
* it under the terms of the GNU Lesser General Public License as |
8
|
|
|
* published by the Free Software Foundation, version 3. |
9
|
|
|
* |
10
|
|
|
* PhpBotFramework is distributed in the hope that it will be useful, but |
11
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13
|
|
|
* Lesser General Public License for more details. |
14
|
|
|
* |
15
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
16
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace PhpBotFramework\Entities; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* \addtogroup Entities Entities |
23
|
|
|
* @{ |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
/** \class CallbackQuery |
27
|
|
|
* \brief This object represents an incoming inline query. |
28
|
|
|
* \details When the user sends an empty query, your bot could return some default or trending results. |
29
|
|
|
*/ |
30
|
|
View Code Duplication |
class InlineQuery implements \ArrayAccess |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
|
33
|
|
|
/** @} */ |
34
|
|
|
|
35
|
|
|
use EntityAccess; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* \brief Get result's query. |
39
|
|
|
* @return string $query If set or <code>null</code> if empty. |
40
|
|
|
*/ |
41
|
|
|
public function getQuery() : string |
42
|
|
|
{ |
43
|
|
|
return isset($this->container['query']) ? $this->container['query'] : null; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* \brief Get the chat ID where the result comes from. |
48
|
|
|
* @return $chat_id Chat ID. |
|
|
|
|
49
|
|
|
*/ |
50
|
|
|
public function getChatID() |
51
|
|
|
{ |
52
|
|
|
return $this->container['from']['id']; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getBotParameter() : array |
56
|
|
|
{ |
57
|
|
|
return ['var' => '_inline_query_id', 'id' => $this->container['id']]; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.