<?php

namespace Soft_Tehnica\Freya_Sync_Service\STUtils;

use Jenssegers\Blade\Blade;
use Throwable;

class STView
{

    /**
         * @param array<string, mixed> $params
         */
    public static function render( string $view, array $params = [] ): string
    {
        $blade = new Blade( sprintf( '%s/views', fsRootPath ), sprintf( '%s/cache', fsRootPath ) );

        try {
            return $blade->render( $view, $params );
        } catch ( Throwable $exception ) {
            return $exception->getMessage() . ' - ' . $exception->getFile() . ' - ' . $exception->getLine();
        }
    }
}
