diff --git a/l18n b/l18n index ca22b13..04b1e8d 160000 --- a/l18n +++ b/l18n @@ -1 +1 @@ -Subproject commit ca22b133ecc12ad49b8d17519571cc2eb8a03df7 +Subproject commit 04b1e8d678fbb37cac7d96b167be5822bab2491a diff --git a/src/enums/MDAppointmentCancellationStatus.php b/src/enums/MDAppointmentCancellationStatus.php new file mode 100644 index 0000000..31a585a --- /dev/null +++ b/src/enums/MDAppointmentCancellationStatus.php @@ -0,0 +1,110 @@ + + */ +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 + */ + 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 + */ + 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 + */ + 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); + + } + + /** + * Provides the option to serialize as a string during json_encode(). + * + * @return string + */ + public function jsonSerialize():string { + + return $this->name; + + } +} diff --git a/src/enums/MDAttendanceStatus.php b/src/enums/MDAttendanceStatus.php new file mode 100644 index 0000000..a064741 --- /dev/null +++ b/src/enums/MDAttendanceStatus.php @@ -0,0 +1,110 @@ + + */ +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 + */ + 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 + */ + 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 + */ + 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); + + } + + /** + * Provides the option to serialize as a string during json_encode(). + * + * @return string + */ + public function jsonSerialize():string { + + return $this->name; + + } +}