175 lines
4.2 KiB
PHP
175 lines
4.2 KiB
PHP
<?PHP
|
|
declare(strict_types = 1);
|
|
|
|
/**
|
|
* Represents an icon available to be selected for ticket types.
|
|
*/
|
|
enum MDInstitutionTicketTypeIcon implements MDValueEnumInterface, JsonSerializable {
|
|
|
|
case person;
|
|
case child;
|
|
case calendar;
|
|
case disabled;
|
|
|
|
/**
|
|
* Returns a value of this type based on a string.
|
|
*
|
|
* @param string $input Input to get a value from.
|
|
*
|
|
* @return MDInstitutionTicketTypeIcon
|
|
*/
|
|
public static function fromString(string $input):MDInstitutionTicketTypeIcon {
|
|
|
|
return match($input) {
|
|
"0",
|
|
"person" => self::person,
|
|
"1",
|
|
"child" => self::child,
|
|
"2",
|
|
"calendar" => self::calendar,
|
|
"3",
|
|
"disabled" => self::disabled,
|
|
default => throw new MDpageParameterNotFromListException("Unknown ticket type icon"),
|
|
};
|
|
|
|
}
|
|
|
|
/**
|
|
* Returns a value of this type based on an integer.
|
|
*
|
|
* @param integer $input Input to get a value from.
|
|
*
|
|
* @return MDInstitutionTicketTypeIcon
|
|
*/
|
|
public static function fromInt(int $input):MDInstitutionTicketTypeIcon {
|
|
|
|
return match($input) {
|
|
0 => self::person,
|
|
1 => self::child,
|
|
2 => self::calendar,
|
|
3 => self::disabled,
|
|
default => throw new MDpageParameterNotFromListException("Unknown ticket type icon"),
|
|
};
|
|
|
|
}
|
|
|
|
/**
|
|
* Lists all available names.
|
|
*
|
|
* @return array<string>
|
|
*/
|
|
public static function caseNames():array {
|
|
|
|
$output = [];
|
|
|
|
$cases = self::cases();
|
|
foreach ($cases as $case) {
|
|
$output[] = $case->toString();
|
|
}
|
|
|
|
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(), "ticket_type_icon", "ticket_type_icon");
|
|
|
|
}
|
|
|
|
/**
|
|
* 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(), "ticket_type_icon", "ticket_type_icon");
|
|
|
|
}
|
|
|
|
/**
|
|
* 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::person => 0,
|
|
self::child => 1,
|
|
self::calendar => 2,
|
|
self::disabled => 3,
|
|
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
|
};
|
|
|
|
}
|
|
|
|
/**
|
|
* Returns string representation.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function toString():string {
|
|
|
|
return match($this) {
|
|
self::person => 'person',
|
|
self::child => 'child',
|
|
self::calendar => 'calendar',
|
|
self::disabled => 'disabled',
|
|
# 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 {
|
|
|
|
if ($this === self::person) return '';
|
|
return $tlLoader->tl("ticket_type_icon", "ticket_type_icon", $this->toString());
|
|
|
|
}
|
|
|
|
/**
|
|
* Provides the option to serialize as a string during json_encode().
|
|
*
|
|
* @return string
|
|
*/
|
|
public function jsonSerialize():string {
|
|
|
|
return $this->toString();
|
|
|
|
}
|
|
}
|