Add new enum for covering series contribution types for actors

This commit is contained in:
Joshua Ramon Enslin 2024-05-07 18:31:50 +02:00
parent 4c1916247b
commit 6772476f9b
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -0,0 +1,174 @@
<?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;
/**
* 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,
default => throw new MDpageParameterNotFromListException("Unknown attendance status"),
};
}
/**
* 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(), "attendance_status_set", "attendance_status_set");
}
/**
* 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(), "attendance_status_set", "attendance_status_set");
}
/**
* 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,
# 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("attendance_status_set", "attendance_status_set", $this->name);
}
/**
* Provides the option to serialize as a string during json_encode().
*
* @return string
*/
public function jsonSerialize():string {
return $this->name;
}
}