<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class BpmnExportCommand extends AbstractCommand
{
    public function name(): string { return 'workflow:bpmn:export'; }
    public function description(): string { return 'PPphp BPMN Export'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp BPMN Export');
        $runtime = \PpPhp\Core\Platform\Workflow\Bpmn\BpmnRuntime::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); $summary = $runtime->summary(); $processId = (string) ($summary['models'][0]['processId'] ?? ''); $xml = $processId !== '' ? $runtime->exportXml($processId) : ''; $this->line('Exported: ' . ($xml !== '' ? 'YES' : 'NO')); $this->line('Bytes: ' . strlen($xml));
        return 0;
    }
}
