<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class StreamMessagesCommand extends AbstractCommand
{
    public function name(): string { return 'stream:messages'; }
    public function description(): string { return 'PPphp Stream Messages'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Stream Messages');
        $bus = \PpPhp\Core\Platform\Event\Streaming\MessageBus::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); foreach ($bus->summary()['messages'] as $envelope) { $message = $envelope['message']; $this->line('- ' . $message['messageId'] . ' topic=' . $message['topic'] . ' type=' . $message['type'] . ' status=' . $envelope['status']); }
        return 0;
    }
}
