Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
9bbb25ce
Unverified
Commit
9bbb25ce
authored
Aug 16, 2016
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix todo of InlineKeyboardButton entity.
Correct DocBlock comments.
parent
3d14b749
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
InlineKeyboardButton.php
src/Entities/InlineKeyboardButton.php
+16
-10
No files found.
src/Entities/InlineKeyboardButton.php
View file @
9bbb25ce
...
@@ -14,32 +14,38 @@ use Longman\TelegramBot\Exception\TelegramException;
...
@@ -14,32 +14,38 @@ use Longman\TelegramBot\Exception\TelegramException;
class
InlineKeyboardButton
extends
Entity
class
InlineKeyboardButton
extends
Entity
{
{
/**#@+
* @var string
*/
protected
$text
;
protected
$text
;
protected
$url
;
protected
$url
;
protected
$callback_data
;
protected
$callback_data
;
protected
$switch_inline_query
;
protected
$switch_inline_query
;
/**#@-*/
/**
/**
* InlineKeyboardButton constructor.
* InlineKeyboardButton constructor.
*
*
* @todo check if only one of 'url, callback_data, switch_inline_query' fields is set, documentation states that only one of these can be used
*
* @param array $data
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
*/
public
function
__construct
(
$data
=
array
()
)
public
function
__construct
(
array
$data
=
[]
)
{
{
$this
->
text
=
isset
(
$data
[
'text'
])
?
$data
[
'text'
]
:
null
;
$this
->
text
=
isset
(
$data
[
'text'
])
?
$data
[
'text'
]
:
null
;
if
(
empty
(
$this
->
text
))
{
if
(
empty
(
$this
->
text
))
{
throw
new
TelegramException
(
'text is empty!'
);
throw
new
TelegramException
(
'text is empty!'
);
}
}
$this
->
url
=
isset
(
$data
[
'url'
])
?
$data
[
'url'
]
:
null
;
$num_params
=
0
;
$this
->
callback_data
=
isset
(
$data
[
'callback_data'
])
?
$data
[
'callback_data'
]
:
null
;
foreach
([
'url'
,
'callback_data'
,
'switch_inline_query'
]
as
$param
)
{
$this
->
switch_inline_query
=
isset
(
$data
[
'switch_inline_query'
])
?
$data
[
'switch_inline_query'
]
:
null
;
if
(
!
empty
(
$data
[
$param
]))
{
$this
->
$param
=
$data
[
$param
];
if
(
$this
->
url
===
''
&&
$this
->
callback_data
===
''
&&
$this
->
switch_inline_query
===
''
)
{
$num_params
++
;
throw
new
TelegramException
(
'You must use at least one of these fields: url, callback_data, switch_inline_query!'
);
}
}
if
(
$num_params
!==
1
)
{
throw
new
TelegramException
(
'You must use only one of these fields: url, callback_data, switch_inline_query!'
);
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment