You've already forked Php-Template
All checks were successful
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 3m1s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 3m16s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 3m13s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 3m5s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 3m11s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 1m51s
Reviewed-on: #14 Co-authored-by: Ron Rise <ron@siteworxpro.com> Co-committed-by: Ron Rise <ron@siteworxpro.com>
42 lines
855 B
PHP
42 lines
855 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Siteworxpro\App\Async\Messages;
|
|
|
|
use Siteworxpro\App\Services\Facades\Broker;
|
|
|
|
class SayHelloMessage extends Message
|
|
{
|
|
public static function dispatch(...$args): void
|
|
{
|
|
$name = $args[0] ?? 'World';
|
|
$message = new self($name);
|
|
Broker::publish(
|
|
$message->getQueue(),
|
|
$message
|
|
);
|
|
}
|
|
|
|
public static function dispatchLater(int $delay, ...$args): void
|
|
{
|
|
$name = $args[0] ?? 'World';
|
|
$message = new self($name);
|
|
Broker::publishLater(
|
|
$message->getQueue(),
|
|
$message,
|
|
$delay
|
|
);
|
|
}
|
|
|
|
private function __construct(
|
|
private readonly string $name
|
|
) {
|
|
parent::__construct();
|
|
|
|
$this->payload = [
|
|
'name' => $this->name,
|
|
];
|
|
}
|
|
}
|