Major Refactoring
This commit is contained in:
parent
3de87df2d9
commit
54a8a59ee8
83 changed files with 892 additions and 918 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
use TgBotLib\Abstracts\BotCommandScopeType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
|
@ -20,7 +21,7 @@
|
|||
private $chat_id;
|
||||
|
||||
/**
|
||||
* Scope type, must be chat_administrators
|
||||
* Scope type, must be all_chat_administrators
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@ -61,8 +62,10 @@
|
|||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
{
|
||||
$object = new self();
|
||||
$object->type = $data['type'];
|
||||
$object->chat_id = $data['chat_id'];
|
||||
|
||||
$object->type = $data['type'] ?? BotCommandScopeType::AllChatAdministrators;
|
||||
$object->chat_id = $data['chat_id'] ?? null;
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
@ -75,8 +78,10 @@
|
|||
public static function fromBotCommandScope(BotCommandScope $botCommandScope): self
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $botCommandScope->getType();
|
||||
$object->chat_id = $botCommandScope->getChatId();
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
use TgBotLib\Abstracts\BotCommandScopeType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
|
@ -46,7 +47,7 @@
|
|||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'];
|
||||
$object->type = $data['type'] ?? BotCommandScopeType::AllGroupChats;
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
use TgBotLib\Abstracts\BotCommandScopeType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
|
@ -46,7 +47,7 @@
|
|||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'];
|
||||
$object->type = $data['type'] ?? BotCommandScopeType::AllPrivateChats;
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
use TgBotLib\Abstracts\BotCommandScopeType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
|
@ -62,8 +63,8 @@
|
|||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'];
|
||||
$object->chat_id = $data['chat_id'];
|
||||
$object->type = $data['type'] ?? BotCommandScopeType::Chat;
|
||||
$object->chat_id = $data['chat_id'] ?? null;
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
use TgBotLib\Abstracts\BotCommandScopeType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
|
@ -46,7 +47,7 @@
|
|||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'];
|
||||
$object->type = $data['type'] ?? BotCommandScopeType::ChatAdministrators;
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
use TgBotLib\Abstracts\BotCommandScopeType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
|
@ -77,9 +78,11 @@
|
|||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
{
|
||||
$object = new self();
|
||||
$object->type = $data['type'];
|
||||
$object->chat_id = $data['chat_id'];
|
||||
$object->user_id = $data['user_id'];
|
||||
|
||||
$object->type = $data['type'] ?? BotCommandScopeType::ChatMember;
|
||||
$object->chat_id = $data['chat_id'] ?? null;
|
||||
$object->user_id = $data['user_id'] ?? null;
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
use TgBotLib\Abstracts\BotCommandScopeType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
|
@ -46,7 +47,7 @@
|
|||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'];
|
||||
$object->type = $data['type'] ?? BotCommandScopeType::Default;
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue