<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class WorkerConsumeCommand extends AbstractCommand
{
    public function name(): string { return 'worker:consume'; }
    public function description(): string { return 'PPphp Queue Consume'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Queue Consume');
        $manager = \PpPhp\Core\Platform\Event\Consumer\QueueConsumerManager::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); $manager->consumer()->queue()->enqueue('consumer.console.single'); $result = $manager->consumer()->consume(static function (): void {}); $manager->save(); $this->line('Consumed: ' . ($result->acknowledged() ? 'YES' : 'NO'));
        return 0;
    }
}
