Added ReactionCount
This commit is contained in:
parent
ba5e446bd2
commit
742f177145
1 changed files with 60 additions and 0 deletions
60
src/TgBotLib/Objects/ReactionCount.php
Normal file
60
src/TgBotLib/Objects/ReactionCount.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects;
|
||||
|
||||
use TgBotLib\Enums\Types\ReactionTypes;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
|
||||
class ReactionCount implements ObjectTypeInterface
|
||||
{
|
||||
private ReactionTypes $type;
|
||||
private int $total_count;
|
||||
|
||||
/**
|
||||
* Type of the reaction
|
||||
*
|
||||
* @return ReactionTypes
|
||||
*/
|
||||
public function getType(): ReactionTypes
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of times the reaction was added
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalCount(): int
|
||||
{
|
||||
return $this->total_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type->value,
|
||||
'total_count' => $this->total_count
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(?array $data): ?ObjectTypeInterface
|
||||
{
|
||||
if($data === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$object = new self();
|
||||
$object->type = ReactionTypes::tryFrom($data['type']);
|
||||
$object->total_count = $data['total_count'];
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue