PhpBotFramework  2.0.2
A framework for Telegram Bots' APIs.
Classes | Functions
Utility classes

Static methods grouped by class and context. More...

Classes

class  PhpBotFramework\Entities\Text
 Contains text helper methods. More...
 

Functions

static array PhpBotFramework\Entities\Text::getHashtags (string $string)
 Get hashtag contained in a string. More...
 
static string PhpBotFramework\Entities\Text::camelCase ($str, array $noStrip=[])
 Convert a string into camelCase style. More...
 
static string PhpBotFramework\Entities\Text::removeUsernameFormattation (string $string, string $tag)
 Remove HTML formattation from Telegram usernames. More...
 
static string PhpBotFramework\Utilities\Paginator::paginateItems ( $items, int $index, Keyboard &$keyboard, callable $format_item, int $item_per_page=3, string $prefix='list', string $delimiter=DELIMITER)
 Paginate a number of items got as a result by a query. More...
 

Detailed Description

Static methods grouped by class and context.

Function Documentation

◆ camelCase()

static string PhpBotFramework\Entities\Text::camelCase (   $str,
array  $noStrip = [] 
)
static

Convert a string into camelCase style.

Take a look here to learn more.

Parameters
string$strThe string to convert.
array$noStrip
Returns
string $str The input string converted to camelCase.

◆ getHashtags()

static array PhpBotFramework\Entities\Text::getHashtags ( string  $string)
static

Get hashtag contained in a string.

Check hashtags in a string using a regular expression. All valid hashtags will be returned in an array. See the following StackOverflow thread to learn more.

Parameters
$stringThe string to check for hashtags.
Returns
array An array of valid hashtags, can be empty.

◆ paginateItems()

static string PhpBotFramework\Utilities\Paginator::paginateItems (   $items,
int  $index,
Keyboard &  $keyboard,
callable  $format_item,
int  $item_per_page = 3,
string  $prefix = 'list',
string  $delimiter = DELIMITER 
)
static

Paginate a number of items got as a result by a query.

Take items to show in the page $index, delimiting in by $delimiter, and call the closure $format_item on each item paginated. Taking a select query result, take items that have to be shown on page of index $index (calculated with $item_per_page).

Parameters
mixed$itemsResult of a select query using pdo object.
int$indexIndex of the page to show.
PhpBotFramework\Entities\InlineKeyboard$keyboardInline keyboard object to call PhpBotFramework\Entities\InlineKeyboard::addListKeyboard() on it for browsing results.
closure$format_itemA closure that take the item to paginate and the keyboard. You can use it to format the item and add some inline keyboard button for each item.
string$prefixPrefix to pass to InlineKeyboard::addListKeyboard.
string$delimiterA string that will be used to concatenate each item.
Returns
string The string message with the items of page $index, with $delimiter between each of them.
See also
PhpBotFramework\Entities\InlineKeyboard

◆ removeUsernameFormattation()

static string PhpBotFramework\Entities\Text::removeUsernameFormattation ( string  $string,
string  $tag 
)
static

Remove HTML formattation from Telegram usernames.

Remove the $modificator html formattation from a message containing Telegram usernames.

Parameters
string$stringto parse.
string$tagFormattation tag to remove.
Returns
string The string, modified if there are usernames. Otherwise $string.