<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class StreamPublishBatchCommand extends AbstractCommand
{
    public function name(): string { return 'stream:publish:batch'; }
    public function description(): string { return 'PPphp Stream Publish Batch'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Stream Publish Batch');
        $manager = \PpPhp\Core\Platform\Event\Streaming\Publisher\PublisherManager::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); $requests = []; for ($i = 1; $i <= 3; $i++) { $requests[] = \PpPhp\Core\Platform\Event\Streaming\Publisher\PublishRequest::create('console.publisher', 'console.stream', 'console.batch', ['i' => $i]); } $results = $manager->publishBatch($requests); $published = 0; foreach ($results as $result) { if ($result->published()) { $published++; } } $this->line('Published: ' . $published); $this->line('Failed: ' . (count($results) - $published));
        return 0;
    }
}
