<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class DistributedRuntimeFullLockCommand extends AbstractCommand
{
    public function name(): string { return 'distributed:lock'; }
    public function description(): string { return 'PPphp Distributed Runtime Lock'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Distributed Runtime Lock');
        $base = \PpPhp\Core\Platform\Console\ConsolePath::basePath(); $result = (new \PpPhp\Core\Platform\Event\Distributed\Validation\DistributedRuntimeFullVerifier())->verify($base); $report = (new \PpPhp\Core\Platform\Event\Distributed\DistributedRuntimeReportWriter())->write($base, $result); $lock = (new \PpPhp\Core\Platform\Event\Distributed\Lock\DistributedRuntimeLockGenerator())->generate($base, $result); $this->line('Status: ' . ($result['ok'] ? 'LOCKED' : 'FAILED')); $this->line('Score: ' . ($result['summary']['score'] ?? 0) . '%'); $this->line('Report: ' . str_replace($base . '/', '', $report)); $this->line('File: ' . str_replace($base . '/', '', $lock)); return $result['ok'] ? 0 : 1;
    }
}
