<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class StreamBroadcastRunCommand extends AbstractCommand
{
    public function name(): string { return 'stream:broadcast:run'; }
    public function description(): string { return 'PPphp Stream Broadcast Run'; }
    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Stream Broadcast Run');
        $base = \PpPhp\Core\Platform\Console\ConsolePath::basePath(); $subscriberRuntime = \PpPhp\Core\Platform\Event\Streaming\Subscriber\StreamSubscriberRuntime::instance($base); $subscriberRuntime->register('broadcast.console.1', 'console.broadcast'); $subscriberRuntime->register('broadcast.console.2', 'console.broadcast'); $result = \PpPhp\Core\Platform\Event\Streaming\Broadcast\StreamBroadcastRuntime::instance($base)->fanOut('console.broadcast.publisher', 'console.broadcast', 'console.broadcast.event', ['sample' => true]); $this->line('Delivered: ' . $result->delivered()); $this->line('Targets: ' . $result->targets());
        return 0;
    }
}
