Moved InputMessageContent

This commit is contained in:
netkas 2024-10-03 21:15:51 -04:00
parent dfb812237b
commit fb2a06024d
17 changed files with 23 additions and 18 deletions

View file

@ -8,7 +8,7 @@
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
use TgBotLib\Objects\Inline\InlineQueryResult;
use TgBotLib\Objects\InputMessageContent;
use TgBotLib\Objects\Inline\InputMessageContent;
class InlineQueryResultArticle extends InlineQueryResult implements ObjectTypeInterface
{

View file

@ -8,7 +8,7 @@
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
use TgBotLib\Objects\Inline\InlineQueryResult;
use TgBotLib\Objects\InputMessageContent;
use TgBotLib\Objects\Inline\InputMessageContent;
use TgBotLib\Objects\MessageEntity;
class InlineQueryResultAudio extends InlineQueryResult implements ObjectTypeInterface

View file

@ -11,7 +11,7 @@
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
use TgBotLib\Objects\Inline\InlineQueryResult;
use TgBotLib\Objects\InputMessageContent;
use TgBotLib\Objects\Inline\InputMessageContent;
class InlineQueryResultContact extends InlineQueryResult implements ObjectTypeInterface
{

View file

@ -11,7 +11,7 @@
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
use TgBotLib\Objects\Inline\InlineQueryResult;
use TgBotLib\Objects\InputMessageContent;
use TgBotLib\Objects\Inline\InputMessageContent;
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
use TgBotLib\Objects\MessageEntity;

View file

@ -12,7 +12,7 @@
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
use TgBotLib\Objects\Inline\InlineQueryResult;
use TgBotLib\Objects\InputMessageContent;
use TgBotLib\Objects\Inline\InputMessageContent;
use TgBotLib\Objects\MessageEntity;
class InlineQueryResultGif extends InlineQueryResult implements ObjectTypeInterface

View file

@ -9,7 +9,7 @@
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
use TgBotLib\Objects\Inline\InlineQueryResult;
use TgBotLib\Objects\InputMessageContent;
use TgBotLib\Objects\Inline\InputMessageContent;
use TgBotLib\Objects\InputMessageContent\InputContactMessageContent;
class InlineQueryResultLocation extends InlineQueryResult implements ObjectTypeInterface

View file

@ -9,7 +9,7 @@
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
use TgBotLib\Objects\Inline\InlineQueryResult;
use TgBotLib\Objects\InputMessageContent;
use TgBotLib\Objects\Inline\InputMessageContent;
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
use TgBotLib\Objects\MessageEntity;

View file

@ -10,7 +10,7 @@
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
use TgBotLib\Objects\Inline\InlineQueryResult;
use TgBotLib\Objects\InputMessageContent;
use TgBotLib\Objects\Inline\InputMessageContent;
use TgBotLib\Objects\InputMessageContent\InputTextMessageContent;
use TgBotLib\Objects\MessageEntity;

View file

@ -8,7 +8,7 @@
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
use TgBotLib\Objects\Inline\InlineQueryResult;
use TgBotLib\Objects\InputMessageContent;
use TgBotLib\Objects\Inline\InputMessageContent;
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
class InlineQueryResultVenue extends InlineQueryResult implements ObjectTypeInterface

View file

@ -10,7 +10,7 @@
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
use TgBotLib\Objects\Inline\InlineQueryResult;
use TgBotLib\Objects\InputMessageContent;
use TgBotLib\Objects\Inline\InputMessageContent;
use TgBotLib\Objects\MessageEntity;
class InlineQueryResultVideo extends InlineQueryResult implements ObjectTypeInterface

View file

@ -10,7 +10,7 @@
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
use TgBotLib\Objects\Inline\InlineQueryResult;
use TgBotLib\Objects\InputMessageContent;
use TgBotLib\Objects\Inline\InputMessageContent;
use TgBotLib\Objects\MessageEntity;
class InlineQueryResultVoice extends InlineQueryResult implements ObjectTypeInterface

View file

@ -0,0 +1,64 @@
<?php
namespace TgBotLib\Objects\Inline;
use InvalidArgumentException;
use TgBotLib\Enums\Types\InputMessageContentType;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent;
use TgBotLib\Objects\InputMessageContent\InputLocationMessageContent;
use TgBotLib\Objects\InputMessageContent\InputTextMessageContent;
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
abstract class InputMessageContent implements ObjectTypeInterface
{
protected InputMessageContentType $type;
/**
* Returns the type for the Input message content
*
* @return InputMessageContentType
*/
public function getType(): InputMessageContentType
{
return $this->type;
}
/**
* @inheritDoc
*/
public abstract function toArray(): array;
/**
* @inheritDoc
*/
public static function fromArray(?array $data): ?InputMessageContent
{
if($data === null)
{
return null;
}
if(isset($data['message_text']))
{
return InputTextMessageContent::fromArray($data);
}
if(isset($data['latitude']) && isset($data['longitude']) && isset($data['tile']) && isset($data['address']))
{
return InputVenueMessageContent::fromArray($data);
}
if(isset($data['latitude']) && isset($data['longitude']))
{
return InputLocationMessageContent::fromArray($data);
}
if(isset($data['title']) && isset($data['description']) && isset($data['payload']))
{
return InputInvoiceMessageContent::fromArray($data);
}
throw new InvalidArgumentException("Invalid object type, unexpected type");
}
}