ruleset = new Ruleset(strict: true); $this->ruleset->GET([ (new Rules(GET_PARAM_NOTE)) ->required() ->type(Type::STRING) ->min(1) ]); $this->ruleset->validate_or_exit(); } private function get_path(): string { $base_path = substr($_ENV["notes"]["md_file_dir"], -1, 1) === "/" ? $_ENV["notes"]["md_file_dir"] : $_ENV["notes"]["md_file_dir"] . "/"; return "{$base_path}{$_GET[GET_PARAM_NOTE]}.md"; } public function exists(): bool { return is_readable($this->get_path()); } public function read(): string { return file_get_contents($this->get_path()); } public function main(): Response { return $this->exists() ? new Response($this->read(), 200, "text/plain") : new Response("Note not found", 404); } }