2022-12-26 00:52:22 +01:00
|
|
|
<?PHP
|
|
|
|
/**
|
|
|
|
* Represents a type of attendance status for events / appointments: offline or online.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
*/
|
|
|
|
declare(strict_types = 1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a type of attendance status for events / appointments: offline or online.
|
|
|
|
*/
|
|
|
|
enum MDAttendanceStatus implements MDValueEnumInterface, JsonSerializable {
|
|
|
|
|
|
|
|
case online;
|
|
|
|
case offline;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a value of this type based on a string.
|
|
|
|
*
|
|
|
|
* @param string $input Input to get a value from.
|
|
|
|
*
|
|
|
|
* @return MDAttendanceStatus
|
|
|
|
*/
|
|
|
|
public static function fromString(string $input):MDAttendanceStatus {
|
|
|
|
|
|
|
|
return match($input) {
|
|
|
|
'online' => self::online,
|
|
|
|
'offline' => self::offline,
|
|
|
|
default => throw new MDpageParameterNotFromListException("Unknown attendance status"),
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the default status.
|
|
|
|
*
|
|
|
|
* @return MDAttendanceStatus
|
|
|
|
*/
|
|
|
|
public static function getDefault():MDAttendanceStatus {
|
|
|
|
|
|
|
|
return self::offline;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-01-25 00:16:31 +01:00
|
|
|
/**
|
|
|
|
* Returns the JSON-LD representation of the attendance mode.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getJsonLd():string {
|
|
|
|
|
|
|
|
return match($this) {
|
|
|
|
self::online => "https://schema.org/OnlineEventAttendanceMode",
|
|
|
|
self::offline => "https://schema.org/OfflineEventAttendanceMode",
|
|
|
|
default => throw new MDpageParameterNotFromListException("Unknown JSON LD for attendance status"),
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-12-26 00:52:22 +01:00
|
|
|
/**
|
|
|
|
* Provides the option to serialize as a string during json_encode().
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function jsonSerialize():string {
|
|
|
|
|
|
|
|
return $this->name;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|