MDAllowedValueSets/src/enums/MDAppointmentCancellationStatus.php

126 lines
3.2 KiB
PHP
Raw Normal View History

<?PHP
/**
* Represents a type of cancellation status for events / appointments.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Represents a type of cancellation status for events / appointments.
*/
enum MDAppointmentCancellationStatus implements MDValueEnumInterface, JsonSerializable {
case scheduled_done;
case cancelled;
/**
* Returns a value of this type based on a string.
*
* @param string $input Input to get a value from.
*
* @return MDAppointmentCancellationStatus
*/
public static function fromString(string $input):MDAppointmentCancellationStatus {
return match($input) {
'scheduled_done' => self::scheduled_done,
'cancelled' => self::cancelled,
default => throw new MDpageParameterNotFromListException("Unknown cancellation status"),
};
}
/**
* Returns the default status.
*
* @return MDAppointmentCancellationStatus
*/
public static function getDefault():MDAppointmentCancellationStatus {
return self::scheduled_done;
}
/**
* 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(), "appointment_cancellation_status_set", "appointment_cancellation_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(), "appointment_cancellation_status_set", "appointment_cancellation_status_set");
}
/**
* 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("appointment_cancellation_status_set", "appointment_cancellation_status_set", $this->name);
}
/**
* Returns the JSON-LD representation of the attendance mode.
*
* @return string
*/
public function getJsonLd():string {
return match($this) {
self::scheduled_done => "https://schema.org/EventScheduled",
self::cancelled => "https://schema.org/EventCancelled",
2023-02-28 21:45:06 +01:00
// default => throw new MDpageParameterNotFromListException("Unknown JSON LD for attendance status"),
};
}
/**
* Provides the option to serialize as a string during json_encode().
*
* @return string
*/
public function jsonSerialize():string {
return $this->name;
}
}