Files
kiri-core/kiri-actor/ActorMessage.php
T

79 lines
1.0 KiB
PHP
Raw Normal View History

2022-10-11 18:20:47 +08:00
<?php
2023-04-16 01:45:34 +08:00
declare(strict_types=1);
2022-10-11 18:20:47 +08:00
namespace Kiri\Actor;
2023-08-28 12:01:30 +08:00
use JetBrains\PhpStorm\ArrayShape;
2022-10-11 18:20:47 +08:00
class ActorMessage implements \JsonSerializable
{
/**
* @var int
*/
private int $userId;
/**
* @var string
*/
private string $event;
/**
* @var array
*/
private array $body;
/**
* @param int $userId
* @param string $event
* @param array $body
*/
public function __construct(int $userId, string $event, array $body)
{
$this->userId = $userId;
$this->event = $event;
$this->body = $body;
}
/**
* @return int
*/
public function getUserId(): int
{
return $this->userId;
}
/**
* @return string
*/
public function getEvent(): string
{
return $this->event;
}
/**
* @return array
*/
public function getBody(): array
{
return $this->body;
}
/**
* @return array
*/
2023-08-28 12:01:30 +08:00
#[ArrayShape(['userId' => "int", 'event' => "string", 'body' => "array"])]
public function jsonSerialize(): array
2022-10-11 18:20:47 +08:00
{
return [
'userId' => $this->userId,
'event' => $this->event,
'body' => $this->body
];
}
}