From 1e3824a87ad60e7b99f5f5922ac9ea7f6ebb7afb Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 30 Sep 2024 12:22:12 -0400 Subject: [PATCH] Updated Methods --- src/TgBotLib/Abstracts/Method.php | 4 +++- src/TgBotLib/Enums/Methods.php | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/TgBotLib/Abstracts/Method.php b/src/TgBotLib/Abstracts/Method.php index 261abde..16be0da 100644 --- a/src/TgBotLib/Abstracts/Method.php +++ b/src/TgBotLib/Abstracts/Method.php @@ -4,6 +4,7 @@ namespace TgBotLib\Abstracts; use CURLFile; use CurlHandle; +use InvalidArgumentException; use TgBotLib\Bot; use TgBotLib\Exceptions\TelegramException; use TgBotLib\Interfaces\ObjectTypeInterface; @@ -17,6 +18,7 @@ abstract class Method * @param array $parameters The parameters required for the bot command. * @return ObjectTypeInterface|ObjectTypeInterface[]|mixed The result of the bot command. * @throws TelegramException if the response from the bot command is not valid. + * @throws InvalidArgumentException if the required parameters are not provided. */ public abstract static function execute(Bot $bot, array $parameters=[]): mixed; @@ -96,7 +98,7 @@ abstract class Method * @throws TelegramException if the response is not a valid array, * or if the 'ok' field is not set or is false. */ - protected static function executeCurl(CurlHandle $curl): array + protected static function executeCurl(CurlHandle $curl): mixed { $response = curl_exec($curl); curl_close($curl); diff --git a/src/TgBotLib/Enums/Methods.php b/src/TgBotLib/Enums/Methods.php index 2ed70ef..ad1d594 100644 --- a/src/TgBotLib/Enums/Methods.php +++ b/src/TgBotLib/Enums/Methods.php @@ -4,11 +4,17 @@ use TgBotLib\Bot; use TgBotLib\Exceptions\TelegramException; + use TgBotLib\Methods\Close; use TgBotLib\Methods\GetMe; + use TgBotLib\Methods\Logout; + use TgBotLib\Methods\SendMessage; enum Methods : string { case GET_ME = 'getMe'; + case LOGOUT = 'logOut'; + case CLOSE = 'close'; + case SEND_MESSAGE = 'sendMessage'; /** * Executes a command on the provided bot with the given parameters. @@ -23,6 +29,9 @@ return match($this) { self::GET_ME => GetMe::execute($bot, $parameters), + self::LOGOUT => LogOut::execute($bot, $parameters), + self::CLOSE => Close::execute($bot, $parameters), + self::SEND_MESSAGE => SendMessage::execute($bot, $parameters), }; } }