Commit 87e0d1c4 authored by Avtandil Kikabidze's avatar Avtandil Kikabidze

Improved code and doc-blocks

parent c6e430a8
...@@ -16,13 +16,7 @@ define('BASE_COMMANDS_PATH', BASE_PATH . '/Commands'); ...@@ -16,13 +16,7 @@ define('BASE_COMMANDS_PATH', BASE_PATH . '/Commands');
use Longman\TelegramBot\Entities\Update; use Longman\TelegramBot\Entities\Update;
use Longman\TelegramBot\Exception\TelegramException; use Longman\TelegramBot\Exception\TelegramException;
/**
* @package Telegram
* @author Avtandil Kikabidze <akalongman@gmail.com>
* @copyright Avtandil Kikabidze <akalongman@gmail.com>
* @license http://opensource.org/licenses/mit-license.php The MIT License (MIT)
* @link http://www.github.com/akalongman/php-telegram-bot
*/
class Telegram class Telegram
{ {
/** /**
...@@ -63,7 +57,7 @@ class Telegram ...@@ -63,7 +57,7 @@ class Telegram
/** /**
* Current Update object * Current Update object
* *
* @var Entities\Update * @var \Longman\TelegramBot\Entities\Update
*/ */
protected $update; protected $update;
...@@ -112,7 +106,7 @@ class Telegram ...@@ -112,7 +106,7 @@ class Telegram
/** /**
* ServerResponse of the last Command execution * ServerResponse of the last Command execution
* *
* @var Entities\ServerResponse * @var \Longman\TelegramBot\Entities\ServerResponse
*/ */
protected $last_command_response; protected $last_command_response;
...@@ -124,10 +118,11 @@ class Telegram ...@@ -124,10 +118,11 @@ class Telegram
protected $botan_enabled = false; protected $botan_enabled = false;
/** /**
* Constructor * Telegram constructor.
* *
* @param string $api_key * @param $api_key
* @param string $bot_name * @param $bot_name
* @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function __construct($api_key, $bot_name) public function __construct($api_key, $bot_name)
{ {
...@@ -158,7 +153,7 @@ class Telegram ...@@ -158,7 +153,7 @@ class Telegram
* @param array $credential * @param array $credential
* @param string $table_prefix * @param string $table_prefix
* *
* @return Telegram * @return \Longman\TelegramBot\Telegram
*/ */
public function enableMySql(array $credential, $table_prefix = null, $encoding = 'utf8mb4') public function enableMySql(array $credential, $table_prefix = null, $encoding = 'utf8mb4')
{ {
...@@ -185,6 +180,7 @@ class Telegram ...@@ -185,6 +180,7 @@ class Telegram
* Get commands list * Get commands list
* *
* @return array $commands * @return array $commands
* @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function getCommandsList() public function getCommandsList()
{ {
...@@ -211,7 +207,6 @@ class Telegram ...@@ -211,7 +207,6 @@ class Telegram
require_once $file->getPathname(); require_once $file->getPathname();
$command_obj = $this->getCommandObject($command); $command_obj = $this->getCommandObject($command);
if ($command_obj instanceof Commands\Command) { if ($command_obj instanceof Commands\Command) {
$commands[$command_name] = $command_obj; $commands[$command_name] = $command_obj;
...@@ -274,7 +269,7 @@ class Telegram ...@@ -274,7 +269,7 @@ class Telegram
/** /**
* Get the ServerResponse of the last Command execution * Get the ServerResponse of the last Command execution
* *
* @return Entities\ServerResponse * @return \Longman\TelegramBot\Entities\ServerResponse
*/ */
public function getLastCommandResponse() public function getLastCommandResponse()
{ {
...@@ -312,7 +307,7 @@ class Telegram ...@@ -312,7 +307,7 @@ class Telegram
if ($response->isOk()) { if ($response->isOk()) {
//Process all updates //Process all updates
foreach ((array) $response->getResult() as $result) { foreach ((array)$response->getResult() as $result) {
$this->processUpdate($result); $this->processUpdate($result);
} }
} }
...@@ -361,9 +356,9 @@ class Telegram ...@@ -361,9 +356,9 @@ class Telegram
/** /**
* Process bot Update request * Process bot Update request
* *
* @param Entities\Update $update * @param \Longman\TelegramBot\Entities\Update $update
* *
* @return Entities\ServerResponse * @return \Longman\TelegramBot\Entities\ServerResponse
*/ */
public function processUpdate(Update $update) public function processUpdate(Update $update)
{ {
...@@ -419,6 +414,7 @@ class Telegram ...@@ -419,6 +414,7 @@ class Telegram
* @param string $command * @param string $command
* *
* @return mixed * @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function executeCommand($command) public function executeCommand($command)
{ {
...@@ -451,7 +447,6 @@ class Telegram ...@@ -451,7 +447,6 @@ class Telegram
return $this->last_command_response; return $this->last_command_response;
} }
/** /**
* Sanitize Command * Sanitize Command
* *
...@@ -469,7 +464,7 @@ class Telegram ...@@ -469,7 +464,7 @@ class Telegram
* *
* @param integer $admin_id Single admin id * @param integer $admin_id Single admin id
* *
* @return Telegram * @return \Longman\TelegramBot\Telegram
*/ */
public function enableAdmin($admin_id) public function enableAdmin($admin_id)
{ {
...@@ -487,7 +482,7 @@ class Telegram ...@@ -487,7 +482,7 @@ class Telegram
* *
* @param array $admin_ids List of admin ids * @param array $admin_ids List of admin ids
* *
* @return Telegram * @return \Longman\TelegramBot\Telegram
*/ */
public function enableAdmins(array $admin_ids) public function enableAdmins(array $admin_ids)
{ {
...@@ -556,7 +551,7 @@ class Telegram ...@@ -556,7 +551,7 @@ class Telegram
* @param string $path Custom commands path to add * @param string $path Custom commands path to add
* @param bool $before If the path should be prepended or appended to the list * @param bool $before If the path should be prepended or appended to the list
* *
* @return Telegram * @return \Longman\TelegramBot\Telegram
*/ */
public function addCommandsPath($path, $before = true) public function addCommandsPath($path, $before = true)
{ {
...@@ -579,7 +574,7 @@ class Telegram ...@@ -579,7 +574,7 @@ class Telegram
* @param array $paths Custom commands paths to add * @param array $paths Custom commands paths to add
* @param bool $before If the paths should be prepended or appended to the list * @param bool $before If the paths should be prepended or appended to the list
* *
* @return Telegram * @return \Longman\TelegramBot\Telegram
*/ */
public function addCommandsPaths(array $paths, $before = true) public function addCommandsPaths(array $paths, $before = true)
{ {
...@@ -703,6 +698,7 @@ class Telegram ...@@ -703,6 +698,7 @@ class Telegram
* @param string|null $path_certificate * @param string|null $path_certificate
* *
* @return \Longman\TelegramBot\Entities\ServerResponse * @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function setWebHook($url, $path_certificate = null) public function setWebHook($url, $path_certificate = null)
{ {
...@@ -724,7 +720,8 @@ class Telegram ...@@ -724,7 +720,8 @@ class Telegram
/** /**
* Unset Webhook for bot * Unset Webhook for bot
* *
* @return \Longman\TelegramBot\Entities\ServerResponse * @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function unsetWebHook() public function unsetWebHook()
{ {
...@@ -762,14 +759,17 @@ class Telegram ...@@ -762,14 +759,17 @@ class Telegram
*/ */
protected function ucfirstUnicode($str, $encoding = 'UTF-8') protected function ucfirstUnicode($str, $encoding = 'UTF-8')
{ {
return mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding) . mb_strtolower(mb_substr($str, 1, mb_strlen($str), $encoding), $encoding); return mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding) . mb_strtolower(mb_substr($str, 1,
mb_strlen($str),
$encoding),
$encoding);
} }
/** /**
* Enable Botan.io integration * Enable Botan.io integration
* *
* @param $token * @param $token
* @return Telegram * @return \Longman\TelegramBot\Telegram
*/ */
public function enableBotan($token) public function enableBotan($token)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment