<?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 QueueCommand extends AbstractCommand
{
    public function name(): string { return 'queue'; }
    public function description(): string { return 'Show deferred queue overview.'; }

    public function handle(array $arguments = []): int
    {
        $summary = (new DeferredQueueManager())->summary();
        $this->title('PPphp Deferred Event Queue');
        $this->line('Default Driver: ' . $summary['defaultDriver']);
        $this->line('Drivers: ' . implode(', ', $summary['drivers']));
        $this->line('Size: ' . ($summary['statistics']['size'] ?? 0));
        $this->line('Status: OK');
        return 0;
    }
}
