tgbotlib/src/TgBotLib/Objects/ChatInviteLink.php
netkas 32d8e233b8 - Remove nullsafe operator from location property
- Fix user serialization in TransactionPartnerUser
 - Remove null check for stickers in StickerSet
 - Fix nullable operator usage in ShippingQuery toArray method
 - Remove null-safe operator for traveler and watcher
 - Fix null-safe operator in PreCheckoutQuery.php
 - Fix null safe operator usage in PollAnswer.php
 - Refactor null checks in PassportData methods
 - Remove nullsafe operator from chat property
 - Refactor web_app handling in MenuButtonWebApp class
 - Fix conditional assignment in InputMediaVideo
 - Fix null coalescing and array mapping in InputMediaAudio
 - Fix redundant null coalescing in caption_entities mapping
 - Fix parsing of caption_entities field in InlineQueryResultPhoto
 - Fix potential unnecessary null coalescing in caption_entities
 - Fix redundant null coalescence check in reply_markup assignment
 - Fix redundant null coalescing in array_map calls
 - Refactor: remove unnecessary null coalescing operator
 - Fix conditional check for caption_entities assignment
 - Fix handling of input_message_content array conversion
 - Fix potential null pointer issue in InlineQuery class
 - Remove redundant null check in toArray method
 - Fix redundant null coalesce operator in photo mapping
 - Remove null safe operator for origin
 - Fix redundant null coalescing in array_map calls.
 - Fix optional chaining error in ChosenInlineResult.php
 - Remove null-safe operator in toArray() method
 - Fix null safe operator usage in ChatMemberRestricted
 - Fix null-safe operator usage in ChatMemberOwner.php
 - Fix null safe operator usage in ChatMemberMember.php
 - Fix nullable operator usage in ChatMemberLeft class
 - Fix null-safe operator in ChatMemberBanned serialization.
 - Fix user attribute null coalescing in ChatMemberAdministrator
 - Fix null-safe operator usage in ChatLocation conversion
 - Remove null safe operator in toArray() method
 - Fix nullable operator usage in ChatInviteLink serialization
 - Fix potential null pointer issue in ChatBoostSourcePremium.
 - Remove null safe operator in ChatBoostRemoved toArray method
 - Fix 'from' property serialization in CallbackQuery
 - Fix nullable operator usage on chat property
 - Remove redundant type check for associative array
 - Remove deprecated BotOld.php file
2024-11-03 18:19:27 -05:00

176 lines
No EOL
5.2 KiB
PHP

<?php
namespace TgBotLib\Objects;
use TgBotLib\Interfaces\ObjectTypeInterface;
class ChatInviteLink implements ObjectTypeInterface
{
private string $invite_link;
private User $creator;
private bool $creates_join_request;
private bool $is_primary;
private bool $is_revoked;
private string $name;
private ?int $expire_date;
private ?int $member_limit;
private ?int $pending_join_request_count;
private ?int $subscription_period;
private ?int $subscription_price;
/**
* The invite link. If the link was created by another chat administrator, then the second part of the link
* will be replaced with “…”.
*
* @return string
*/
public function getInviteLink(): string
{
return $this->invite_link;
}
/**
* Creator of the link
*
* @return User
*/
public function getCreator(): User
{
return $this->creator;
}
/**
* True, if users joining the chat via the link need to be approved by chat administrators
*
* @return bool
*/
public function createsJoinRequest(): bool
{
return $this->creates_join_request;
}
/**
* True, if the link is primary
*
* @return bool
*/
public function isPrimary(): bool
{
return $this->is_primary;
}
/**
* True, if the link is revoked
*
* @return bool
*/
public function isRevoked(): bool
{
return $this->is_revoked;
}
/**
* Optional. Invite link name
*
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* Optional. Point in time (Unix timestamp) when the link will expire or has been expired
*
* @return int|null
*/
public function getExpireDate(): ?int
{
return $this->expire_date;
}
/**
* Optional. The maximum number of users that can be members of the chat simultaneously after joining the
* chat via this invite link; 1-99999
*
* @return int|null
*/
public function getMemberLimit(): ?int
{
return $this->member_limit;
}
/**
* Optional. Number of pending join requests created using this link
*
* @return int|null
*/
public function getPendingJoinRequestCount(): ?int
{
return $this->pending_join_request_count;
}
/**
* Optional. The number of seconds the subscription will be active for before the next payment
*
* @return int|null
*/
public function getSubscriptionPeriod(): ?int
{
return $this->subscription_period;
}
/**
* Optional. The amount of Telegram Stars a user must pay initially and after each subsequent subscription
* period to be a member of the chat using the link
*
* @return int|null
*/
public function getSubscriptionPrice(): ?int
{
return $this->subscription_price;
}
/**
* @inheritDoc
*/
public function toArray(): array
{
return [
'invite_link' => $this->invite_link,
'creator' => $this->creator->toArray(),
'creates_join_request' => $this->creates_join_request ?? false,
'is_primary' => $this->is_primary ?? false,
'is_revoked' => $this->is_revoked ?? false,
'name' => $this->name,
'expire_date' => $this->expire_date,
'member_limit' => $this->member_limit,
'pending_join_request_count' => $this->pending_join_request_count,
'subscription_period' => $this->subscription_period,
'subscription_price' => $this->subscription_price
];
}
/**
* @inheritDoc
*/
public static function fromArray(?array $data): ChatInviteLink
{
$object = new self();
$object->invite_link = $data['invite_link'] ?? null;
$object->creator = isset($data['creator']) ? User::fromArray($data['creator']) : null;
$object->creates_join_request = $data['creates_join_request'] ?? null;
$object->is_primary = $data['is_primary'] ?? null;
$object->is_revoked = $data['is_revoked'] ?? null;
$object->name = $data['name'] ?? null;
$object->expire_date = $data['expire_date'] ?? null;
$object->member_limit = $data['member_limit'] ?? null;
$object->pending_join_request_count = $data['pending_join_request_count'] ?? null;
$object->subscription_period = $data['subscription_period'] ?? null;
$object->subscription_price = $data['subscription_price'] ?? null;
return $object;
}
}