checkCategoryCache($id); if (!$category) { throw new BadRequestException('question_query.invalid_category'); } return $category->id; } public function checkTag($id) { $tagCache = new TagCache(); $tag = $tagCache->get($id); if (!$tag) { throw new BadRequestException('question_query.invalid_tag'); } return $tag->id; } public function checkSort($sort) { $types = QuestionModel::sortTypes(); if (!isset($types[$sort])) { throw new BadRequestException('question_query.invalid_sort'); } return $sort; } }