Major Refactoring

This commit is contained in:
Netkas 2023-02-14 17:35:16 -05:00
parent 3de87df2d9
commit 54a8a59ee8
83 changed files with 892 additions and 918 deletions

View file

@ -4,6 +4,7 @@
namespace TgBotLib\Objects\ChatMember;
use TgBotLib\Abstracts\ChatMemberStatus;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\ChatMember;
use TgBotLib\Objects\User;
@ -125,7 +126,7 @@
*
* @return bool
*/
public function isIsMember(): bool
public function isMember(): bool
{
return $this->is_member;
}
@ -135,7 +136,7 @@
*
* @return bool
*/
public function isCanSendMessages(): bool
public function canSendMessages(): bool
{
return $this->can_send_messages;
}
@ -145,7 +146,7 @@
*
* @return bool
*/
public function isCanSendAudios(): bool
public function canSendAudios(): bool
{
return $this->can_send_audios;
}
@ -155,7 +156,7 @@
*
* @return bool
*/
public function isCanSendDocuments(): bool
public function canSendDocuments(): bool
{
return $this->can_send_documents;
}
@ -165,7 +166,7 @@
*
* @return bool
*/
public function isCanSendPhotos(): bool
public function canSendPhotos(): bool
{
return $this->can_send_photos;
}
@ -175,7 +176,7 @@
*
* @return bool
*/
public function isCanSendVideos(): bool
public function canSendVideos(): bool
{
return $this->can_send_videos;
}
@ -185,7 +186,7 @@
*
* @return bool
*/
public function isCanSendVideoNotes(): bool
public function canSendVideoNotes(): bool
{
return $this->can_send_video_notes;
}
@ -195,7 +196,7 @@
*
* @return bool
*/
public function isCanSendVoiceNotes(): bool
public function canSendVoiceNotes(): bool
{
return $this->can_send_voice_notes;
}
@ -205,7 +206,7 @@
*
* @return bool
*/
public function isCanSendPolls(): bool
public function canSendPolls(): bool
{
return $this->can_send_polls;
}
@ -215,7 +216,7 @@
*
* @return bool
*/
public function isCanSendOtherMessages(): bool
public function canSendOtherMessages(): bool
{
return $this->can_send_other_messages;
}
@ -225,7 +226,7 @@
*
* @return bool
*/
public function isCanAddWebPagePreviews(): bool
public function canAddWebPagePreviews(): bool
{
return $this->can_add_web_page_previews;
}
@ -235,7 +236,7 @@
*
* @return bool
*/
public function isCanChangeInfo(): bool
public function canChangeInfo(): bool
{
return $this->can_change_info;
}
@ -245,7 +246,7 @@
*
* @return bool
*/
public function isCanInviteUsers(): bool
public function canInviteUsers(): bool
{
return $this->can_invite_users;
}
@ -255,7 +256,7 @@
*
* @return bool
*/
public function isCanPinMessages(): bool
public function canPinMessages(): bool
{
return $this->can_pin_messages;
}
@ -265,7 +266,7 @@
*
* @return bool
*/
public function isCanManageTopics(): bool
public function canManageTopics(): bool
{
return $this->can_manage_topics;
}
@ -314,29 +315,30 @@
*
* @param array $data
* @return ObjectTypeInterface
* @noinspection DuplicatedCode
*/
public static function fromArray(array $data): ObjectTypeInterface
{
$object = new static();
$object->status = $data['status'];
$object->status = $data['status'] ?? ChatMemberStatus::Restricted;
$object->user = isset($data['user']) ? User::fromArray($data['user']) : null;
$object->is_member = @$data['is_member'] ?? false;
$object->can_send_messages = @$data['can_send_messages'] ?? false;
$object->can_send_audios = @$data['can_send_audios'] ?? false;
$object->can_send_documents = @$data['can_send_documents'] ?? false;
$object->can_send_photos = @$data['can_send_photos'] ?? false;
$object->can_send_videos = @$data['can_send_videos'] ?? false;
$object->can_send_video_notes = @$data['can_send_video_notes'] ?? false;
$object->can_send_voice_notes = @$data['can_send_voice_notes'] ?? false;
$object->can_send_polls = @$data['can_send_polls'] ?? false;
$object->can_send_other_messages = @$data['can_send_other_messages'] ?? false;
$object->can_add_web_page_previews = @$data['can_add_web_page_previews'] ?? false;
$object->can_change_info = @$data['can_change_info'] ?? false;
$object->can_invite_users = @$data['can_invite_users'] ?? false;
$object->can_pin_messages = @$data['can_pin_messages'] ?? false;
$object->can_manage_topics = @$data['can_manage_topics'] ?? false;
$object->until_date = @$data['until_date'] ?? 0;
$object->is_member = $data['is_member'] ?? false;
$object->can_send_messages = $data['can_send_messages'] ?? false;
$object->can_send_audios = $data['can_send_audios'] ?? false;
$object->can_send_documents = $data['can_send_documents'] ?? false;
$object->can_send_photos = $data['can_send_photos'] ?? false;
$object->can_send_videos = $data['can_send_videos'] ?? false;
$object->can_send_video_notes = $data['can_send_video_notes'] ?? false;
$object->can_send_voice_notes = $data['can_send_voice_notes'] ?? false;
$object->can_send_polls = $data['can_send_polls'] ?? false;
$object->can_send_other_messages = $data['can_send_other_messages'] ?? false;
$object->can_add_web_page_previews = $data['can_add_web_page_previews'] ?? false;
$object->can_change_info = $data['can_change_info'] ?? false;
$object->can_invite_users = $data['can_invite_users'] ?? false;
$object->can_pin_messages = $data['can_pin_messages'] ?? false;
$object->can_manage_topics = $data['can_manage_topics'] ?? false;
$object->until_date = $data['until_date'] ?? 0;
return $object;
}
@ -353,21 +355,21 @@
$object->status = $chatMember->getStatus();
$object->user = $chatMember->getUser();
$object->is_member = $chatMember->isIsMember();
$object->can_send_messages = $chatMember->isCanSendMessages();
$object->can_send_audios = $chatMember->isCanSendAudios();
$object->can_send_documents = $chatMember->isCanSendDocuments();
$object->can_send_photos = $chatMember->isCanSendPhotos();
$object->can_send_videos = $chatMember->isCanSendVideos();
$object->can_send_video_notes = $chatMember->isCanSendVideoNotes();
$object->can_send_voice_notes = $chatMember->isCanSendVoiceNotes();
$object->can_send_polls = $chatMember->isCanSendPolls();
$object->can_send_other_messages = $chatMember->isCanSendOtherMessages();
$object->can_add_web_page_previews = $chatMember->isCanAddWebPagePreviews();
$object->can_change_info = $chatMember->isCanChangeInfo();
$object->can_invite_users = $chatMember->isCanInviteUsers();
$object->can_pin_messages = $chatMember->isCanPinMessages();
$object->can_manage_topics = $chatMember->isCanManageTopics();
$object->is_member = $chatMember->isMember();
$object->can_send_messages = $chatMember->canSendMessages();
$object->can_send_audios = $chatMember->canSendAudios();
$object->can_send_documents = $chatMember->canSendDocuments();
$object->can_send_photos = $chatMember->canSendPhotos();
$object->can_send_videos = $chatMember->canSendVideos();
$object->can_send_video_notes = $chatMember->canSendVideoNotes();
$object->can_send_voice_notes = $chatMember->canSendVoiceNotes();
$object->can_send_polls = $chatMember->canSendPolls();
$object->can_send_other_messages = $chatMember->canSendOtherMessages();
$object->can_add_web_page_previews = $chatMember->canAddWebPagePreviews();
$object->can_change_info = $chatMember->canChangeInfo();
$object->can_invite_users = $chatMember->canInviteUsers();
$object->can_pin_messages = $chatMember->canPinMessages();
$object->can_manage_topics = $chatMember->canManageTopics();
$object->until_date = $chatMember->getUntilDate();
return $object;