Message extends Notice
Represents a text message emitted by a Signal.
This class encapsulates the details of an event, including:
- The type of the event (
$type). - The text of message (
$text). - The target object that triggered the event (
$target). - Additional contextual information related to the event (
$context).
It is typically used as the payload when emitting signals:
$signal->emit( new Message
(
type : 'info' ,
text : 'Hello World' ,
target : $signal
));
Tags
Table of Contents
Properties
- $context : array<string|int, mixed>
- The context of the notice
- $target : mixed
- The target of the notice.
- $text : string
- The message of the notice
- $type : mixed
- The type of the notice.
Methods
- __construct() : mixed
- Creates a new Message.
- jsonSerialize() : array<string|int, mixed>
- Serializes the current object into a JSON array.
- toArray() : array<string|int, mixed>
- Returns the array representation of the notice object.
Properties
$context
The context of the notice
public
array<string|int, mixed>
$context
$target
The target of the notice.
public
mixed
$target
$text
The message of the notice
public
string
$text
$type
The type of the notice.
public
mixed
$type
Methods
__construct()
Creates a new Message.
public
__construct(string $type[, string $text = '' ][, object|null $target = null ][, array<string|int, mixed> $context = [] ]) : mixed
Parameters
- $type : string
-
The type of the notice.
- $text : string = ''
-
The text of the message.
- $target : object|null = null
-
The target of the notice.
- $context : array<string|int, mixed> = []
-
The context of the notice.
jsonSerialize()
Serializes the current object into a JSON array.
public
jsonSerialize() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —JSON-LD representation of the object.
toArray()
Returns the array representation of the notice object.
public
toArray() : array<string|int, mixed>