<?php

	use Reflect\{Response, Path};
	use Reflect\Rules\{Ruleset, Rules, Type};

	use VLW\Database\Database;
	use VLW\Database\Tables\Work\{TagsTable, TagsLabelEnum};

	require_once Path::root("src/Database/Database.php");
	require_once Path::root("src/Database/Tables/Work/Tags.php");

	class GET_WorkTags extends Database {
		private Ruleset $ruleset;

		public function __construct() {
			$this->ruleset = new Ruleset(strict: true);

			$this->ruleset->GET([
				(new Rules(TagsTable::REF_WORK_ID->value))
					->min(1)
					->max(parent::SIZE_VARCHAR),
				
				(new Rules(TagsTable::LABEL->value))
					->type(Type::ENUM, TagsLabelEnum::names())
			]);

			$this->ruleset->validate_or_exit();

			parent::__construct();
		}

		public function main(): Response {
			return $this->list(TagsTable::NAME, TagsTable::values());
		}
	}