* * * * * ```` */ abstract class TemplateBase{ /** * @param array $arguments */ public static function __callStatic(string $function, array $arguments): string{ // Expand the passed variables to make them available to the included template. // We use these funny names so that we can use `name` and `value` as template variables if we want to. foreach($arguments as $innerName => $innerValue){ $$innerName = $innerValue; } ob_start(); include(TEMPLATES_PATH . '/' . $function . '.php'); $contents = ob_get_contents() ?: ''; ob_end_clean(); return $contents; } /** * Exit the script while outputting the given HTTP code. * * @param bool $showPage If **`TRUE`**, show a special page given the HTTP code (like a 404 page). * * @return never */ public static function ExitWithCode(Enums\HttpCode $httpCode, bool $showPage = true, Enums\HttpRequestType $requestType = Enums\HttpRequestType::Web): void{ http_response_code($httpCode->value); if($requestType == Enums\HttpRequestType::Web && $showPage){ switch($httpCode){ case Enums\HttpCode::Forbidden: include(WEB_ROOT . '/403.php'); break; case Enums\HttpCode::NotFound: include(WEB_ROOT . '/404.php'); break; } } exit(); } }