<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class WorkerConsumerCommand extends AbstractCommand
{
    public function name(): string { return 'worker:consumer'; }
    public function description(): string { return 'PPphp Queue Consumer'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Queue Consumer');
        $manager = \PpPhp\Core\Platform\Event\Consumer\QueueConsumerManager::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); $stats = $manager->consoleState()->statistics(); $this->line('Pending: ' . $stats['pending']); $this->line('Consumed: ' . $stats['consumed']); $this->line('Acknowledged: ' . $stats['acknowledged']); $this->line('Persisted: ' . ($manager->consoleState()->persisted() ? 'YES' : 'NO')); $this->line('Status: OK');
        return 0;
    }
}
