*/ declare(strict_types = 1); /** * Represents the use case an institution uses museum-digital's tools for. */ enum MDInstitutionUseCase implements MDValueEnumInterface, JsonSerializable { case collection_management; case publication; case collection_management_and_publication; /** * Returns a value of this type based on a string. * * @param string $input Input to get a value from. * * @return MDInstitutionUseCase */ public static function fromString(string $input):MDInstitutionUseCase { return match($input) { "collection_management" => self::collection_management, "publication" => self::publication, "collection_management_and_publication" => self::collection_management_and_publication, default => throw new MDpageParameterNotFromListException("Unknown use case for museum-digital"), }; } /** * Returns a value of this type based on an integer. * * @param integer $input Input to get a value from. * * @return MDInstitutionUseCase */ public static function fromInt(int $input):MDInstitutionUseCase { return match($input) { 0 => self::collection_management, 1 => self::publication, 2 => self::collection_management_and_publication, default => throw new MDpageParameterNotFromListException("Unknown use case for museum-digital"), }; } /** * Lists all available names. * * @return array */ public static function caseNames():array { $output = []; $cases = self::cases(); foreach ($cases as $case) { $output[] = $case->name; } return $output; } /** * Gets an unsorted list of the entries in a translated version. * * @param MDTlLoader $tlLoader Translation loader. * * @return array */ public static function getUnsortedList(MDTlLoader $tlLoader):array { return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "institution_musdb_use_case_set", "institution_musdb_use_case_set"); } /** * Gets a sorted list of the entries in a translated version. * * @param MDTlLoader $tlLoader Translation loader. * * @return array */ public static function getSortedList(MDTlLoader $tlLoader):array { return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "institution_musdb_use_case_set", "institution_musdb_use_case_set"); } /** * Lists all available names. * * @return array */ public static function caseInts():array { $output = []; $cases = self::cases(); foreach ($cases as $case) { $output[] = $case->toInt(); } return $output; } /** * Returns integer representation of object record status. * * @return integer */ public function toInt():int { return match($this) { self::collection_management => 0, self::publication => 1, self::collection_management_and_publication => 2, # default => throw new MDpageParameterNotFromListException("Unknown object record status"), }; } /** * Returns the name of the current value in translation. * * @param MDTlLoader $tlLoader Translation loader. * * @return string */ public function getTledName(MDTlLoader $tlLoader):string { return $tlLoader->tl("institution_musdb_use_case_set", "institution_musdb_use_case_set", $this->name); } /** * Provides the option to serialize as a string during json_encode(). * * @return string */ public function jsonSerialize():string { return $this->name; } }