Final Class Yiisoft\Queue\Message\GenericMessage
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
A general-purpose immutable {@see MessageInterface} implementation that holds a message type and its payload data.
Prefer creating custom message classes that better express your domain.
Public Methods
Method Details
| public mixed __construct ( string $type, boolean|integer|float|string|array|null $payload ) | ||
| $type | string |
A message type used to resolve the handler. Must be a non-empty string. |
| $payload | boolean|integer|float|string|array|null |
Message payload data. Must contain only |
public function __construct(
private readonly string $type,
private readonly bool|int|float|string|array|null $payload,
) {
/**
* @psalm-suppress TypeDoesNotContainType Guard against an empty type passed without static analysis.
*/
if ($this->type === '') {
throw new InvalidArgumentException('Message type must be a non-empty string.');
}
}
| public static static fromPayload ( string $type, boolean|integer|float|string|array|null $payload ) | ||
| $type | string | |
| $payload | boolean|integer|float|string|array|null | |
public static function fromPayload(string $type, bool|int|float|string|array|null $payload): static
{
return new self($type, $payload);
}
Defined in:
Yiisoft\
| public array getMeta ( ) |
final public function getMeta(): array
{
return $this->meta;
}
| public bool|int|float|string|array|null getPayload ( ) |
public function getPayload(): bool|int|float|string|array|null
{
return $this->payload;
}
Defined in:
Yiisoft\
| public static withMeta ( array $meta ) | ||
| $meta | array | |
final public function withMeta(array $meta): static
{
$new = clone $this;
$new->meta = $meta;
return $new;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.