<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class WorkerQuarantineReleaseCommand extends AbstractCommand
{
    public function name(): string { return 'worker:quarantine:release'; }
    public function description(): string { return 'PPphp Worker Quarantine Release'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Worker Quarantine Release');
        $manager = \PpPhp\Core\Platform\Event\Worker\Monitoring\WorkerQuarantineManager::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); $summary = $manager->summary(); $released = false; foreach ($summary['records'] as $record) { if (($record['active'] ?? false) === true) { $released = $manager->release((string) $record['workerId']); break; } } $this->line('Released: ' . ($released ? 'YES' : 'NO'));
        return 0;
    }
}
