0 follower

Final Class Yiisoft\Queue\Message\GenericMessage

InheritanceYiisoft\Queue\Message\GenericMessage » Yiisoft\Queue\Message\Message
ImplementsYiisoft\Queue\Message\MessageInterface

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.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( string $type, boolean|integer|float|string|array|null $payload )
$type string

A message type used to resolve the handler.

$payload boolean|integer|float|string|array|null

Message payload data. Must contain only null, scalars (bool, int, float, string), or arrays composed of the same types recursively.

                public function __construct(
    private readonly string $type,
    private readonly bool|int|float|string|array|null $payload,
) {}

            
fromPayload() public static method

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);
}

            
getMeta() public method
public array getMeta ( )

                final public function getMeta(): array
{
    return $this->meta;
}

            
getPayload() public method

public bool|int|float|string|array|null getPayload ( )

                public function getPayload(): bool|int|float|string|array|null
{
    return $this->payload;
}

            
getType() public method

public string getType ( )

                public function getType(): string
{
    return $this->type;
}

            
withMeta() public method
public static withMeta ( array $meta )
$meta array

                final public function withMeta(array $meta): static
{
    $new = clone $this;
    $new->meta = $meta;
    return $new;
}