tgbotlib/src/TgBotLib/Objects/Dice.php

56 lines
1.1 KiB
PHP
Raw Normal View History

2023-02-12 17:21:43 -05:00
<?php
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
{
2024-10-04 15:04:16 -04:00
private string $emoji;
private int $value;
2023-02-12 17:21:43 -05:00
/**
* @return string
*/
public function getEmoji(): string
{
return $this->emoji;
}
/**
* @return int
*/
public function getValue(): int
{
return $this->value;
}
/**
2024-10-04 15:04:16 -04:00
* @inheritDoc
2023-02-12 17:21:43 -05:00
*/
public function toArray(): array
{
return [
'emoji' => $this->emoji,
'value' => $this->value,
];
}
/**
2024-10-04 15:04:16 -04:00
* @inheritDoc
2023-02-12 17:21:43 -05:00
*/
2024-10-04 15:04:16 -04:00
public static function fromArray(?array $data): ?Dice
2023-02-12 17:21:43 -05:00
{
2024-10-04 15:04:16 -04:00
if($data === null)
{
return null;
}
2023-02-12 17:21:43 -05:00
2024-10-04 15:04:16 -04: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;
}
}