tgbotlib/src/TgBotLib/Objects/Dice.php

65 lines
1.3 KiB
PHP
Raw Normal View History

2023-02-12 17:21:43 -05:00
<?php
/** @noinspection PhpMissingFieldTypeInspection */
2024-10-02 00:18:12 -04:00
namespace TgBotLib\Objects;
2023-02-12 17:21:43 -05:00
use TgBotLib\Interfaces\ObjectTypeInterface;
class Dice implements ObjectTypeInterface
{
/**
* @var string
*/
private $emoji;
/**
* @var int
*/
private $value;
/**
* @return string
*/
public function getEmoji(): string
{
return $this->emoji;
}
/**
* @return int
*/
public function getValue(): int
{
return $this->value;
}
/**
* Constructs object from array representation
*
* @return array
*/
public function toArray(): array
{
return [
'emoji' => $this->emoji,
'value' => $this->value,
];
}
/**
* Constructs object from array representation
*
* @param array $data
2023-02-16 15:27:57 -05:00
* @return Dice
2023-02-12 17:21:43 -05:00
*/
2023-02-16 15:27:57 -05:00
public static function fromArray(array $data): self
2023-02-12 17:21:43 -05:00
{
$object = new self();
2023-02-14 17:35:16 -05:00
$object->emoji = $data['emoji'] ?? null;
$object->value = $data['value'] ?? null;
2023-02-12 17:21:43 -05:00
return $object;
}
}