<?php
// app/Helpers/View.php

class View {
    public static function render($view, $data = []) {
        extract($data);
        $file = 'app/Views/' . str_replace('.', '/', $view) . '.php';
        if (file_exists($file)) {
            require $file;
        } else {
            echo "View not found: $file";
        }
    }

    public static function layout($layout, $view, $data = []) {
        extract($data);
        $content_view = 'app/Views/' . str_replace('.', '/', $view) . '.php';
        $layout_file  = 'app/Views/layouts/' . $layout . '.php';
        ob_start();
        if (file_exists($content_view)) {
            require $content_view;
        }
        $content = ob_get_clean();
        require $layout_file;
    }
}
