<?php

declare(strict_types=1);

namespace App\Core;

use RuntimeException;

class View
{
    public static function render(
        string $view,
        array $data = []
    ): void {
        $viewFile = APP_PATH
            . '/Views/'
            . str_replace('.', '/', $view)
            . '.php';

        if (!is_file($viewFile)) {
            throw new RuntimeException(
                'View not found: ' . $view
            );
        }

        extract($data, EXTR_SKIP);

        require $viewFile;
    }
}