<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;
use PpPhp\Core\Platform\Event\Queue\DeferredQueueManager;

final class QueueStatsCommand extends AbstractCommand
{
    public function name(): string { return 'queue:stats'; }
    public function description(): string { return 'Show deferred queue statistics.'; }

    public function handle(array $arguments = []): int
    {
        $stats = (new DeferredQueueManager())->statistics()->toArray();
        $this->title('PPphp Deferred Queue Stats');
        foreach ($stats as $key => $value) {
            $this->line($key . ': ' . $value);
        }
        return 0;
    }
}
