Added set methods to \TgBotLib\Objects\Telegram\InputMessageContent\InputTextMessageContent

https://git.n64.cc/nosial/libs/tgbot/-/issues/3
This commit is contained in:
Netkas 2023-04-30 14:01:51 -04:00
parent 5ce6f737f5
commit 40d25a15f1
No known key found for this signature in database
GPG key ID: 5DAF58535614062B

View file

@ -1,9 +1,12 @@
<?php
/** @noinspection PhpUnused */
/** @noinspection PhpMissingFieldTypeInspection */
namespace TgBotLib\Objects\Telegram\InputMessageContent;
use InvalidArgumentException;
use TgBotLib\Classes\Validate;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\MessageEntity;
@ -39,6 +42,22 @@
return $this->message_text;
}
/**
* Sets the value of 'message_text' property
* Text of the message to be sent, 1-4096 characters
*
* @param string $message_text
* @return $this
*/
public function setMessageText(string $message_text): self
{
if(!Validate::length($message_text, 1, 4096))
throw new InvalidArgumentException('message_text should be between 1-4096 characters');
$this->message_text = $message_text;
return $this;
}
/**
* Optional. Mode for parsing entities in the message text.
*
@ -50,6 +69,28 @@
return $this->parse_mode;
}
/**
* Sets the value of 'parse_mode' property
* Optional. Mode for parsing entities in the message text.
*
* @param string|null $parse_mode
* @return $this
*/
public function setParseMode(?string $parse_mode): self
{
if($parse_mode == null)
{
$this->parse_mode = null;
return $this;
}
if(!in_array(strtolower($parse_mode), ['markdown', 'html']))
throw new InvalidArgumentException('parse_mode should be either Markdown or HTML');
$this->parse_mode = strtolower($parse_mode);
return $this;
}
/**
* Optional. List of special entities that appear in message text, which can be specified instead of parse_mode
*
@ -60,16 +101,55 @@
return $this->entities;
}
/**
* Sets the value of 'entities' property
* Optional. List of special entities that appear in message text, which can be specified instead of parse_mode
*
* @param MessageEntity[]|null $entities
* @return $this
*/
public function setEntities(?array $entities): self
{
if($entities == null)
{
$this->entities = null;
return $this;
}
foreach($entities as $entity)
{
if(!($entity instanceof MessageEntity))
throw new InvalidArgumentException('entities should be an array of MessageEntity objects');
}
$this->entities = $entities;
return $this;
}
/**
* Optional. Disables link previews for links in the sent message
*
* @return bool
* @noinspection PhpUnused
*/
public function isDisableWebPagePreview(): bool
{
return $this->disable_web_page_preview;
}
/**
* Sets the value of 'disable_web_page_preview' property
* Optional. Disables link previews for links in the sent message
*
* @param bool $disable_web_page_preview
* @return $this
*/
public function setDisableWebPagePreview(bool $disable_web_page_preview): self
{
$this->disable_web_page_preview = $disable_web_page_preview;
return $this;
}
/**
* Returns an array representation of the object
*