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

    public function handle(array $arguments = []): int
    {
        $manager = new DeferredQueueManager();
        $manager->enqueue('queue.flush.sample');
        $flushed = $manager->flush(static function (): void {});
        $this->title('PPphp Deferred Queue Flush');
        $this->line('Flushed: ' . $flushed);
        return 0;
    }
}
