diff --git a/classes/HTTPStatus.php b/classes/HTTPStatus.php index 5355dca7c4410ec6e1e858695a6fbe83209e59bf..2d2b721bee6493baee63ee6a19c417f2e158e157 100644 --- a/classes/HTTPStatus.php +++ b/classes/HTTPStatus.php @@ -1,52 +1,52 @@ -<?php +<?php declare(strict_types=1); namespace uib\ub\loadspeakr; use stdClass; -class HTTPStatus +final class HTTPStatus { - public static function send303($uri, $ext) + public static function send303($uri, $ext): void { header("HTTP/1.0 303 See Other"); header("Location: " . $uri); header("Content-type: " . $ext); - echo HTTPStatus::_getContent("303", $uri); + echo self::getContent("303", $uri); exit(0); } - public static function send401($uri) + public static function send401($uri): void { header("HTTP/1.0 401 Forbidden"); - echo HTTPStatus::_getContent("401", $uri); + echo self::getContent("401", $uri); exit(0); } - public static function send404($uri) + public static function send404($uri): void { header("HTTP/1.0 404 Not Found"); $alt = "LODSPeaKr couldn't find the resource " . $uri; - echo HTTPStatus::_getContent("404", $alt); + echo self::getContent("404", $alt); exit(0); } - public static function send406($uri) + public static function send406($uri): void { header("HTTP/1.0 406 Not Acceptable"); $alt = "LODSPeaKr can't return content acceptable according to the Accept headers sent in the request for " . $uri; - echo HTTPStatus::_getContent("406", $alt); + echo self::getContent("406", $alt); exit(0); } - public static function send500($uri) + public static function send500($uri): void { header("HTTP/1.0 500 Internal Server Error"); $alt = "There was an internal error when processing " . $uri; - echo HTTPStatus::_getContent("500", $alt); + echo self::getContent("500", $alt); exit(0); } - private static function _getContent($n, $alt) + private static function getContent($n, $alt): string { global $conf; global $lodspk; @@ -61,10 +61,10 @@ class HTTPStatus $file = $conf['httpStatus']['directory'] . "/" . $n . ".template"; if (file_exists($conf['home'] . $file)) { - require_once("Utils.php"); Utils::showView($lodspk, new stdClass(), $file); - } else { - return $alt . "\n\n"; + return ''; } + + return $alt . "\n\n"; } }