<?php

namespace App\Framework\View\Loading;

final readonly class TemplateContentLoader
{
    public function load(string $path): string
    {
        if (!file_exists($path)) {
            throw new \RuntimeException("Template file not found: {$path}");
        }

        $content = @file_get_contents($path);

        if ($content === false) {
            throw new \RuntimeException("Template could not be read: {$path}");
        }

        // HTML-Entities dekodieren, damit -> nicht als &gt; erscheint
        return html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
    }
}
