<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class BpmnCompileCommand extends AbstractCommand
{
    public function name(): string { return 'workflow:bpmn:compile'; }
    public function description(): string { return 'PPphp BPMN Compile'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp BPMN Compile');
        $runtime = \PpPhp\Core\Platform\Workflow\Bpmn\BpmnRuntime::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); $summary = $runtime->summary(); $processId = (string) ($summary['models'][0]['processId'] ?? ''); $compiled = $processId !== '' ? $runtime->compile($processId) : null; $this->line('Compiled: ' . ($compiled ? 'YES' : 'NO')); if ($compiled) { $this->line('Workflow: ' . $compiled->workflowId()); }
        return 0;
    }
}
