From 7199a2c6edf6f356bb7f3dc482c8ca8aa4a000c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D1=96=D0=B9?= <61122611+CrazyTapok-bit@users.noreply.github.com> Date: Mon, 22 Apr 2024 18:39:05 +0300 Subject: [PATCH] Add PHPDoc --- src/Bot.php | 33 ++++++++++++++++++++++++++ src/TgWebValid.php | 22 +++++++++++++++++ src/Validator/InitDataValidator.php | 3 +++ src/Validator/LoginWidgetValidator.php | 1 + 4 files changed, 59 insertions(+) diff --git a/src/Bot.php b/src/Bot.php index ef5c851..2ddb9db 100644 --- a/src/Bot.php +++ b/src/Bot.php @@ -4,6 +4,7 @@ use TgWebValid\Entities\InitData; use TgWebValid\Entities\LoginWidget; +use TgWebValid\Exceptions\ValidationException; use TgWebValid\Validator\InitDataValidator; use TgWebValid\Validator\LoginWidgetValidator; @@ -16,6 +17,23 @@ public function __construct( { } + /** + * + * Validate Telegram Mini App user + * + * They say we are cool 😎 + * + * ⭐️ Support us, give us a star on GitHub and become our sponsor 😊 + * + * 🙏 Please let us know on GitHub if something isn't working for you + * or if you need additional functionality + * + * @throws ValidationException If the validation fails and receiving exceptions is enabled in the settings + * + * @link https://github.com/CrazyTapok-bit/tgWebValid GitHub + * @link https://tgwebvalid.com Documentation + * @link https://patreon.com/user?u=9918808 Patreon + */ public function validateInitData(string $initData, ?bool $throw = null): InitData|false { $validator = new InitDataValidator( @@ -26,7 +44,22 @@ public function validateInitData(string $initData, ?bool $throw = null): InitDat } /** + * + * Validate Telegram Login Widget user + * + * They say we are cool 😎 + * + * ⭐️ Support us, give us a star on GitHub and become our sponsor 😊 + * + * 🙏 Please let us know on GitHub if something isn't working for you + * or if you need additional functionality + * * @param array $user + * @throws ValidationException If the validation fails and receiving exceptions is enabled in the settings + * + * @link https://github.com/CrazyTapok-bit/tgWebValid GitHub + * @link https://tgwebvalid.com Documentation + * @link https://patreon.com/user?u=9918808 Patreon */ public function validateLoginWidget(array $user, ?bool $throw = null): LoginWidget|false { diff --git a/src/TgWebValid.php b/src/TgWebValid.php index 9a87439..83acc3e 100644 --- a/src/TgWebValid.php +++ b/src/TgWebValid.php @@ -4,6 +4,20 @@ use TgWebValid\Exceptions\BotException; +/** + * Library for Telegram Web App User validation and Telegram Login Widget for PHP + * + * They say we are cool 😎 + * + * ⭐️ Support us, give us a star on GitHub and become our sponsor 😊 + * + * 🙏 Please let us know on GitHub if something isn't working for you + * or if you need additional functionality + * + * @link https://github.com/CrazyTapok-bit/tgWebValid GitHub + * @link https://tgwebvalid.com Documentation + * @link https://patreon.com/user?u=9918808 Patreon + */ final class TgWebValid { /** @@ -18,11 +32,19 @@ public function __construct( { } + /** + * Allows you to add an extra bot to your setup if you need to work with multiple + */ public function addBot(string $name, string $token): void { $this->bots[$name] = new BotConfig($name, $token); } + /** + * It helps to choose a bot with which you need to interact + * + * @throws BotException If the bot you are requesting does not exist in the settings + */ public function bot(?string $name = null): Bot { if(!$name){ diff --git a/src/Validator/InitDataValidator.php b/src/Validator/InitDataValidator.php index e005e14..ea63af5 100644 --- a/src/Validator/InitDataValidator.php +++ b/src/Validator/InitDataValidator.php @@ -7,6 +7,9 @@ final class InitDataValidator extends Validator { + /** + * @throws ValidationException If the validation fails and receiving exceptions is enabled in the settings + */ public function validate(string $data): InitData|false { $rawData = $this->parse($data); diff --git a/src/Validator/LoginWidgetValidator.php b/src/Validator/LoginWidgetValidator.php index d634086..48f43e7 100644 --- a/src/Validator/LoginWidgetValidator.php +++ b/src/Validator/LoginWidgetValidator.php @@ -9,6 +9,7 @@ final class LoginWidgetValidator extends Validator { /** * @param array $data + * @throws ValidationException If the validation fails and receiving exceptions is enabled in the settings */ public function validate(array $data): LoginWidget|false {