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

https://git.n64.cc/nosial/libs/tgbot/-/issues/3
This commit is contained in:
Netkas 2023-04-27 23:48:29 -04:00
parent 2389839a37
commit 5ce6f737f5
2 changed files with 121 additions and 5 deletions

View file

@ -57,7 +57,7 @@
private $reply_markup;
/**
* @var InputMessageContent|null
* @var InputMessageContent\InputContactMessageContent|InputMessageContent\InputInvoiceMessageContent|InputMessageContent\InputLocationMessageContent|InputMessageContent\InputTextMessageContent|InputMessageContent\InputVenueMessageContent|null
*/
private $input_message_content;
@ -93,6 +93,7 @@
* A valid URL for the voice recording
*
* @return string
* @noinspection PhpUnused
*/
public function getVoiceUrl(): string
{
@ -143,6 +144,7 @@
* Optional. Recording duration in seconds
*
* @return int|null
* @noinspection PhpUnused
*/
public function getVoiceDuration(): ?int
{
@ -162,9 +164,9 @@
/**
* Optional. Content of the message to be sent instead of the voice recording
*
* @return InputMessageContent|null
* @return InputMessageContent\InputContactMessageContent|InputMessageContent\InputInvoiceMessageContent|InputMessageContent\InputLocationMessageContent|InputMessageContent\InputTextMessageContent|InputMessageContent\InputVenueMessageContent|null
*/
public function getInputMessageContent(): ?InputMessageContent
public function getInputMessageContent(): InputMessageContent\InputContactMessageContent|InputMessageContent\InputInvoiceMessageContent|InputMessageContent\InputLocationMessageContent|InputMessageContent\InputTextMessageContent|InputMessageContent\InputVenueMessageContent|null
{
return $this->input_message_content;
}
@ -173,7 +175,6 @@
* Returns an array representation of the object.
*
* @return array
* @throws \TgBotLib\Exceptions\NotImplementedException
*/
public function toArray(): array
{
@ -193,7 +194,7 @@
})($this->caption_entities ?? null),
'voice_duration' => $this->voice_duration,
'reply_markup' => ($this->reply_markup instanceof InlineKeyboardMarkup) ? $this->reply_markup->toArray() : null,
'input_message_content' => ($this->input_message_content instanceof InputMessageContent) ? $this->input_message_content->toArray() : null,
'input_message_content' => ($this->input_message_content instanceof ObjectTypeInterface) ? $this->input_message_content->toArray() : null,
];
}
@ -202,6 +203,7 @@
*
* @param array $data
* @return ObjectTypeInterface
* @noinspection DuplicatedCode
*/
public static function fromArray(array $data): ObjectTypeInterface
{

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;
class
@ -49,6 +52,19 @@
return $this->latitude;
}
/**
* Sets the value of 'latitude' property
* Latitude of the location in degrees
*
* @param float $latitude
* @return $this
*/
public function setLatitude(float $latitude): self
{
$this->latitude = $latitude;
return $this;
}
/**
* Longitude of the location in degrees
*
@ -59,6 +75,19 @@
return $this->longitude;
}
/**
* Sets the value of 'longitude' property
* Longitude of the location in degrees
*
* @param float $longitude
* @return $this
*/
public function setLongitude(float $longitude): self
{
$this->longitude = $longitude;
return $this;
}
/**
* Optional. The radius of uncertainty for the location, measured in meters; 0-1500
*
@ -69,6 +98,24 @@
return $this->horizontal_accuracy;
}
/**
* Sets the value of 'horizontal_accuracy' property
*
* @param float|null $horizontal_accuracy
* @return $this
*/
public function setHorizontalAccuracy(?float $horizontal_accuracy): self
{
if($horizontal_accuracy == null)
{
$this->horizontal_accuracy = null;
return $this;
}
$this->horizontal_accuracy = $horizontal_accuracy;
return $this;
}
/**
* Optional. Period in seconds for which the location can be updated, should be between 60 and 86400.
*
@ -79,6 +126,28 @@
return $this->live_period;
}
/**
* Sets the value of 'live_period' property
* Optional. Period in seconds for which the location can be updated, should be between 60 and 86400.
*
* @param int|null $live_period
* @return $this
*/
public function setLivePeriod(?int $live_period): self
{
if($live_period)
{
$this->live_period = null;
return $this;
}
if($live_period < 60 || $live_period > 86400)
throw new InvalidArgumentException('live_period should be a value between 60-86400');
$this->live_period = $live_period;
return $this;
}
/**
* Optional. For live locations, a direction in which the user is moving, in degrees.
* Must be between 1 and 360 if specified.
@ -90,6 +159,29 @@
return $this->heading;
}
/**
* Sets the value of 'heading' property
* Optional. For live locations, a direction in which the user is moving, in degrees.
* Must be between 1 and 360 if specified.
*
* @param int|null $heading
* @return $this
*/
public function setHeading(?int $heading): self
{
if($heading == null)
{
$this->heading = null;
return $this;
}
if($heading < 1 || $heading > 360)
throw new InvalidArgumentException('heading should be a value between 1-360');
$this->heading = $heading;
return $this;
}
/**
* Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member,
* in meters. Must be between 1 and 100000 if specified.
@ -101,6 +193,28 @@
return $this->proximity_alert_radius;
}
/**
* Sets the value of 'proximity_alert_radius' property
* Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member,
*
* @param int|null $proximity_alert_radius
* @return $this
*/
public function setProximityAlertRadius(?int $proximity_alert_radius): self
{
if($proximity_alert_radius == null)
{
$this->proximity_alert_radius = null;
return $this;
}
if(!Validate::length($proximity_alert_radius, 1, 100000))
throw new InvalidArgumentException('proximity_alert_radius should be between 1-100000 characters');
$this->proximity_alert_radius = $proximity_alert_radius;
return $this;
}
/**
* Returns an array representation of the object
*