<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class StreamPublishDelayCommand extends AbstractCommand
{
    public function name(): string { return 'stream:publish:delay'; }
    public function description(): string { return 'PPphp Stream Publish Delay'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Stream Publish Delay');
        $result = \PpPhp\Core\Platform\Event\Streaming\Publisher\PublisherManager::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath())->publish(\PpPhp\Core\Platform\Event\Streaming\Publisher\PublishRequest::create('console.publisher', 'console.stream', 'console.delayed', ['sample' => true], [], 1, 30)); $this->line('Published: ' . ($result->published() ? 'YES' : 'NO')); $this->line('Message: ' . $result->messageId());
        return 0;
    }
}
