MDAllowedValueSets/src/enums/MDSeriesContributorRole.php

222 lines
6.1 KiB
PHP

<?PHP
/**
* Represents a type of contribution to an object group.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Represents a type of contribution to an object group.
*/
enum MDSeriesContributorRole implements MDValueEnumInterface, JsonSerializable {
case author;
case director;
case dramaturg;
case production_designer;
case costumer;
case musician;
case choreographer;
case make_up_artist;
case speech_trainer;
case puppet_maker;
case technician;
case inspector;
case assistant;
case actor;
case painter;
case creator;
case equipment_supplier;
case contributing_institution;
case event_organizer;
case movement_trainer;
/**
* Returns a value of this type based on a string.
*
* @param string $input Input to get a value from.
*
* @return MDSeriesContributorRole
*/
public static function fromString(string $input):MDSeriesContributorRole {
return match($input) {
"author" => self::author,
"director" => self::director,
"dramaturg" => self::dramaturg,
"production_designer" => self::production_designer,
"costumer" => self::costumer,
"musician" => self::musician,
"choreographer" => self::choreographer,
"make_up_artist" => self::make_up_artist,
"speech_trainer" => self::speech_trainer,
"puppet_maker" => self::puppet_maker,
"technician" => self::technician,
"inspector" => self::inspector,
"assistant" => self::assistant,
"actor" => self::actor,
"painter" => self::painter,
"creator" => self::creator,
"equipment_supplier" => self::equipment_supplier,
"contributing_institution" => self::contributing_institution,
"event_organizer" => self::event_organizer,
"movement_trainer" => self::movement_trainer,
default => throw new MDpageParameterNotFromListException("Unknown series contributor role"),
};
}
/**
* Returns a value of this type based on an integer.
*
* @param integer $input Input to get a value from.
*
* @return MDSeriesContributorRole
*/
public static function fromInt(int $input):MDSeriesContributorRole {
return match($input) {
0 => self::author,
1 => self::director,
2 => self::dramaturg,
3 => self::production_designer,
4 => self::costumer,
5 => self::musician,
6 => self::choreographer,
7 => self::make_up_artist,
8 => self::speech_trainer,
9 => self::puppet_maker,
10 => self::technician,
11 => self::inspector,
12 => self::assistant,
13 => self::actor,
14 => self::painter,
15 => self::creator,
16 => self::equipment_supplier,
17 => self::contributing_institution,
18 => self::event_organizer,
19 => self::movement_trainer,
default => throw new MDpageParameterNotFromListException("Unknown series contributor role"),
};
}
/**
* Lists all available names.
*
* @return array<string>
*/
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<string, string>
*/
public static function getUnsortedList(MDTlLoader $tlLoader):array {
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "series_contributor_role", "series_contributor_role");
}
/**
* Gets a sorted list of the entries in a translated version.
*
* @param MDTlLoader $tlLoader Translation loader.
*
* @return array<string, string>
*/
public static function getSortedList(MDTlLoader $tlLoader):array {
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "series_contributor_role", "series_contributor_role");
}
/**
* Lists all available names.
*
* @return array<integer>
*/
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::author => 0,
self::director => 1,
self::dramaturg => 2,
self::production_designer => 3,
self::costumer => 4,
self::musician => 5,
self::choreographer => 6,
self::make_up_artist => 7,
self::speech_trainer => 8,
self::puppet_maker => 9,
self::technician => 10,
self::inspector => 11,
self::assistant => 12,
self::actor => 13,
self::painter => 14,
self::creator => 15,
self::equipment_supplier => 16,
self::contributing_institution => 17,
self::event_organizer => 18,
self::movement_trainer => 19,
# 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("series_contributor_role", "series_contributor_role", $this->name);
}
/**
* Provides the option to serialize as a string during json_encode().
*
* @return string
*/
public function jsonSerialize():string {
return $this->name;
}
}