<?php

	namespace VLW\Database\Models\About;

	use \VV;

	use VLW\API\Endpoints;
	use VLW\Database\Models\Model;
	use VLW\Database\Tables\About\LanguagesTable;

	require_once VV::root("src/Consts.php");
	require_once VV::root("src/API/Endpoints.php");
	require_once VV::root("src/Database/Models/Model.php");
	require_once VV::root("src/Database/Tables/About/Languages.php");

	class Language extends Model {
		public function __construct(public readonly string $id) {
			parent::__construct(Endpoints::ABOUT_LANGUAGES, [
				LanguagesTable::ID->value => $this->id
			]);
		}

		public static function all(array $params = []): array {
			return array_map(fn(array $item): Language => new Language($item[LanguagesTable::ID->value]), parent::list(Endpoints::ABOUT_LANGUAGES, $params));
		}

		public function bytes(): int {
			return $this->get(LanguagesTable::BYTES->value);
		}
	}