ServerResponse
extends Entity
in package
Class ServerResponse
Tags
Table of Contents
- __call() : mixed|null
- Return the variable for the called getter or magically set properties dynamically.
- __construct() : mixed
- ServerResponse constructor.
- __toString() : string
- Perform to string
- escapeMarkdown() : string
- Escape markdown special characters
- getBotUsername() :
- getDescription() :
- getErrorCode() :
- getOk() :
- getProperty() : mixed
- Get a property from the current Entity
- getRawData() :
- getResult() :
- isOk() : bool
- If response is ok
- printError() : bool|string
- Print error
- toJson() : string
- Perform to json
- tryMention() : string|null
- Try to mention the user
- assignMemberVariables() : mixed
- Helper to set member variables
- isAssoc() : bool
- Check if array is associative
- makePrettyObjectArray() : array<string|int, mixed>
- Return an array of nice objects from an array of object arrays
- subEntities() : array<string|int, mixed>
- Get the list of the properties that are themselves Entities
- validate() : mixed
- Perform any special entity validation
- createResultObject() : Chat|ChatMember|File|Message|User|UserProfilePhotos|WebhookInfo
- Create and return the object of the received result
- createResultObjects() : null|array<string|int, ChatMember>|array<string|int, Update>
- Create and return the objects array of the received result
Methods
__call()
Return the variable for the called getter or magically set properties dynamically.
public
__call( $method, $args) : mixed|null
Parameters
Return values
mixed|null —__construct()
ServerResponse constructor.
public
__construct(array<string|int, mixed> $data, string $bot_username) : mixed
Parameters
- $data : array<string|int, mixed>
- $bot_username : string
Tags
Return values
mixed —__toString()
Perform to string
public
__toString() : string
Return values
string —escapeMarkdown()
Escape markdown special characters
public
escapeMarkdown(string $string) : string
Parameters
- $string : string
Return values
string —getBotUsername()
public
getBotUsername() :
Return the bot name passed to this entity
Return values
—getDescription()
public
getDescription() :
Human-readable description of the result / unsuccessful request
Return values
—getErrorCode()
public
getErrorCode() :
Error code of the unsuccessful request
Return values
—getOk()
public
getOk() :
If the request was successful
Return values
—getProperty()
Get a property from the current Entity
public
getProperty(mixed $property[, mixed $default = null ]) : mixed
Parameters
- $property : mixed
- $default : mixed = null
Return values
mixed —getRawData()
public
getRawData() :
Get the raw data passed to this entity
Return values
—getResult()
public
getResult() :
The result of the query
Return values
—isOk()
If response is ok
public
isOk() : bool
Return values
bool —printError()
Print error
public
printError([bool $return = false ]) : bool|string
Parameters
- $return : bool = false
Tags
Return values
bool|string —toJson()
Perform to json
public
toJson() : string
Return values
string —tryMention()
Try to mention the user
public
tryMention([bool $escape_markdown = false ]) : string|null
Mention the user with the username otherwise print first and last name if the $escape_markdown argument is true special characters are escaped from the output
Parameters
- $escape_markdown : bool = false
Return values
string|null —assignMemberVariables()
Helper to set member variables
protected
assignMemberVariables(array<string|int, mixed> $data) : mixed
Parameters
- $data : array<string|int, mixed>
Return values
mixed —isAssoc()
Check if array is associative
protected
isAssoc(array<string|int, mixed> $array) : bool
Parameters
- $array : array<string|int, mixed>
Tags
Return values
bool —makePrettyObjectArray()
Return an array of nice objects from an array of object arrays
protected
makePrettyObjectArray(string $class, string $property) : array<string|int, mixed>
This method is used to generate pretty object arrays mainly for PhotoSize and Entities object arrays.
Parameters
- $class : string
- $property : string
Return values
array<string|int, mixed> —subEntities()
Get the list of the properties that are themselves Entities
protected
subEntities() : array<string|int, mixed>
Return values
array<string|int, mixed> —validate()
Perform any special entity validation
protected
validate() : mixed
Tags
Return values
mixed —createResultObject()
Create and return the object of the received result
private
createResultObject(array<string|int, mixed> $result, string $bot_username) : Chat|ChatMember|File|Message|User|UserProfilePhotos|WebhookInfo
Parameters
- $result : array<string|int, mixed>
- $bot_username : string
Tags
Return values
Chat|ChatMember|File|Message|User|UserProfilePhotos|WebhookInfo —createResultObjects()
Create and return the objects array of the received result
private
createResultObjects(array<string|int, mixed> $result, string $bot_username) : null|array<string|int, ChatMember>|array<string|int, Update>
Parameters
- $result : array<string|int, mixed>
- $bot_username : string