<?php
declare(strict_types=1);

namespace App\Modules\Workflow;

use App\Core\Contracts\WorkflowEngineInterface;
use App\Modules\Workflow\Services\WorkflowEngine;

final class WorkflowEngineAdapter implements WorkflowEngineInterface
{
    public function createInstance(string $workflowCode, string $entityType, int $entityId, ?array $stateData = null): object
    {
        return WorkflowEngine::createInstance($workflowCode, $entityType, $entityId, $stateData);
    }

    public function transition(int $instanceId, string $transitionName, ?string $notes = null, string $triggerType = 'manual'): bool
    {
        return WorkflowEngine::transition($instanceId, $transitionName, $notes, $triggerType);
    }

    public function getAvailableTransitions(int $instanceId): array
    {
        return WorkflowEngine::getAvailableTransitions($instanceId);
    }

    public function transitionByEntity(string $entityType, int $entityId, string $transitionName, ?string $notes = null): bool
    {
        return WorkflowEngine::transitionByEntity($entityType, $entityId, $transitionName, $notes);
    }

    public function getCurrentState(string $entityType, int $entityId, ?string $workflowCode = null): ?string
    {
        return WorkflowEngine::getCurrentState($entityType, $entityId, $workflowCode);
    }

    public function getHistory(int $instanceId): array
    {
        return WorkflowEngine::getHistory($instanceId);
    }
}
