query->title ?? false; if ($id === null) { if($title) { $res = MusicAPI::findAllSongByTitleContaining($title); } else { $res = MusicAPI::findAllSong(); } Flight::json(["results" => $res]); } else { $res = MusicAPI::findSongById($id); if ($res) { Flight::json($res); } else { Flight::halt(404); } } } function findAlbum($id = null) { $name = Flight::request()->query->name ?? false; if ($id === null) { if ($name){ $res = MusicAPI::findAlbumByNameContaining($name); } else { $res = MusicAPI::findAllAlbum(); } Flight::json(["results" => $res]); } else { $res = MusicAPI::findAlbumById($id); if ($res) { Flight::json($res); } else { Flight::halt(404); } } } function findArtist($id = null) { $name = Flight::request()->query->name ?? false; if ($id === null) { if ($name){ $res = MusicAPI::findArtsistByNameContaining($name); } else { $res = MusicAPI::findAllArtist(); } Flight::json(["results" => $res]); } else { $res = MusicAPI::findArtsistById($id); if ($res) { Flight::json($res); } else { Flight::halt(404); } } } Flight::start(); ?>