uri = explode('/', $uri); array_shift($this->uri); // Get the request method $this->method = $_SERVER['REQUEST_METHOD']; // Get all headers $this->headers = $this->getAllHeaders(); } public function uri(int $index): string|false { if ($index == 0 && empty($this->uri[0])) return '/'; return $this->uri[$index] ?? false; } private function getAllHeaders(): array { $headers = []; foreach ($_SERVER as $k => $v) { if (substr($k, 0, 5) == 'HTTP_') { $headers[str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($k, 5)))))] = $v; } } return $headers; } }