Skip to content

Commit

Permalink
Add PHPDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyTapok-bit committed Apr 22, 2024
1 parent bdb7c25 commit 7199a2c
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/Bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use TgWebValid\Entities\InitData;
use TgWebValid\Entities\LoginWidget;
use TgWebValid\Exceptions\ValidationException;
use TgWebValid\Validator\InitDataValidator;
use TgWebValid\Validator\LoginWidgetValidator;

Expand All @@ -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(
Expand All @@ -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<string, int|string|bool> $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
{
Expand Down
22 changes: 22 additions & 0 deletions src/TgWebValid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand All @@ -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){
Expand Down
3 changes: 3 additions & 0 deletions src/Validator/InitDataValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/Validator/LoginWidgetValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ final class LoginWidgetValidator extends Validator
{
/**
* @param array<string, int|string|bool> $data
* @throws ValidationException If the validation fails and receiving exceptions is enabled in the settings
*/
public function validate(array $data): LoginWidget|false
{
Expand Down

0 comments on commit 7199a2c

Please sign in to comment.