Moved Objects
This commit is contained in:
parent
848a2a78e3
commit
6c67e97a4b
167 changed files with 368 additions and 373 deletions
68
src/TgBotLib/Objects/MenuButton/MenuButtonCommands.php
Normal file
68
src/TgBotLib/Objects/MenuButton/MenuButtonCommands.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\MenuButton;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\MenuButton;
|
||||
|
||||
class MenuButtonCommands implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* Type of the button, must be commands
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->getType(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return MenuButtonCommands
|
||||
*/
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? null;
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from MenuButton
|
||||
*
|
||||
* @param MenuButton $menuButton
|
||||
* @return MenuButtonCommands
|
||||
*/
|
||||
public static function fromMenuButton(MenuButton $menuButton): MenuButtonCommands
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $menuButton->getType();
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
68
src/TgBotLib/Objects/MenuButton/MenuButtonDefault.php
Normal file
68
src/TgBotLib/Objects/MenuButton/MenuButtonDefault.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\MenuButton;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\MenuButton;
|
||||
|
||||
class MenuButtonDefault implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* Type of the button, must be default
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->getType(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return MenuButtonDefault
|
||||
*/
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? null;
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from MenuButton
|
||||
*
|
||||
* @param MenuButton $menuButton
|
||||
* @return MenuButtonDefault
|
||||
*/
|
||||
public static function fromMenuButton(MenuButton $menuButton): MenuButtonDefault
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $menuButton->getType();
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
108
src/TgBotLib/Objects/MenuButton/MenuButtonWebApp.php
Normal file
108
src/TgBotLib/Objects/MenuButton/MenuButtonWebApp.php
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\MenuButton;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\MenuButton;
|
||||
use TgBotLib\Objects\WebAppInfo;
|
||||
|
||||
class MenuButtonWebApp implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $text;
|
||||
|
||||
/**
|
||||
* @var WebAppInfo
|
||||
*/
|
||||
private $web_app;
|
||||
|
||||
/**
|
||||
* Type of the button, must be web_app
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Text on the button
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText(): string
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description of the Web App that will be launched when the user presses the button. The Web App will be able
|
||||
* to send an arbitrary message on behalf of the user using the method answerWebAppQuery.
|
||||
*
|
||||
* @see https://core.telegram.org/bots/api#answerwebappquery
|
||||
* @return WebAppInfo
|
||||
*/
|
||||
public function getWebApp(): WebAppInfo
|
||||
{
|
||||
return $this->web_app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'text' => $this->text,
|
||||
'web_app' => ($this->web_app instanceof ObjectTypeInterface) ? $this->web_app->toArray() : null
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return MenuButtonWebApp
|
||||
*/
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? null;
|
||||
$object->text = $data['text'] ?? null;
|
||||
$object->web_app = isset($data['web_app']) ? WebAppInfo::fromArray($data['web_app']) : null;
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from MenuButton
|
||||
*
|
||||
* @param MenuButton $menuButton
|
||||
* @return MenuButtonWebApp
|
||||
*/
|
||||
public static function fromMenuButton(MenuButton $menuButton): MenuButtonWebApp
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $menuButton->getType();
|
||||
$object->text = $menuButton->getText();
|
||||
$object->web_app = $menuButton->getWebApp();
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue