Add enums for roles of places and times linked to series
This commit is contained in:
parent
25e5e954b4
commit
e55e4c210a
2
l18n
2
l18n
@ -1 +1 @@
|
||||
Subproject commit ff2a2948323857a5bff2f9b1ab39f63009b35475
|
||||
Subproject commit e863da6ffe66d9edcf14452d185d56eeebf1a178
|
153
src/enums/MDSeriesPlaceRole.php
Normal file
153
src/enums/MDSeriesPlaceRole.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a type of place related to an object group.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of place related to an object group.
|
||||
*/
|
||||
enum MDSeriesPlaceRole implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case place_of_production;
|
||||
case performance_space;
|
||||
case rehearsal_space;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDSeriesPlaceRole
|
||||
*/
|
||||
public static function fromString(string $input):MDSeriesPlaceRole {
|
||||
|
||||
return match($input) {
|
||||
"place_of_production" => self::place_of_production,
|
||||
"performance_space" => self::performance_space,
|
||||
"rehearsal_space" => self::rehearsal_space,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown series place role"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDSeriesPlaceRole
|
||||
*/
|
||||
public static function fromInt(int $input):MDSeriesPlaceRole {
|
||||
|
||||
return match($input) {
|
||||
0 => self::place_of_production,
|
||||
1 => self::performance_space,
|
||||
2 => self::rehearsal_space,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown series place 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_place_role", "series_place_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_place_role", "series_place_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::place_of_production => 0,
|
||||
self::performance_space => 1,
|
||||
self::rehearsal_space => 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("series_place_role", "series_place_role", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
149
src/enums/MDSeriesTimeRole.php
Normal file
149
src/enums/MDSeriesTimeRole.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a type of time related to an object group.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of time related to an object group.
|
||||
*/
|
||||
enum MDSeriesTimeRole implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case premiere;
|
||||
case time_of_presentation;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDSeriesTimeRole
|
||||
*/
|
||||
public static function fromString(string $input):MDSeriesTimeRole {
|
||||
|
||||
return match($input) {
|
||||
"premiere" => self::premiere,
|
||||
"time_of_presentation" => self::time_of_presentation,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown series time role"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDSeriesTimeRole
|
||||
*/
|
||||
public static function fromInt(int $input):MDSeriesTimeRole {
|
||||
|
||||
return match($input) {
|
||||
0 => self::premiere,
|
||||
1 => self::time_of_presentation,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown series time 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_time_role", "series_time_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_time_role", "series_time_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::premiere => 0,
|
||||
self::time_of_presentation => 1,
|
||||
# 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_time_role", "series_time_role", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user