From bb4640ae2cbd9525143773facd79b96c82f3c47b Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Thu, 21 May 2026 15:06:43 +0200 Subject: [PATCH] Add MDAppointmentContributorRole --- src/enums/MDAppointmentContributorRole.php | 162 +++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 src/enums/MDAppointmentContributorRole.php diff --git a/src/enums/MDAppointmentContributorRole.php b/src/enums/MDAppointmentContributorRole.php new file mode 100644 index 0000000..b4a6bcd --- /dev/null +++ b/src/enums/MDAppointmentContributorRole.php @@ -0,0 +1,162 @@ + + */ +declare(strict_types = 1); + +/** + * Represents a type of contribution to an appointment. + */ +enum MDAppointmentContributorRole implements MDValueEnumInterface, JsonSerializable { + + case organizer; + case presenter; + + /** + * Returns a value of this type based on a string. + * + * @param string $input Input to get a value from. + * + * @return MDAppointmentContributorRole + */ + public static function fromString(string $input):MDAppointmentContributorRole { + + return match($input) { + "organizer" => self::organizer, + "presenter" => self::presenter, + default => throw new MDpageParameterNotFromListException("Unknown appointment contributor role"), + }; + + } + + /** + * Returns a value of this type based on an integer. + * + * @param integer $input Input to get a value from. + * + * @return MDAppointmentContributorRole + */ + public static function fromInt(int $input):MDAppointmentContributorRole { + + return match($input) { + 0 => self::organizer, + 1 => self::presenter, + default => throw new MDpageParameterNotFromListException("Unknown appointment contributor role"), + }; + + } + + /** + * 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_contributor_roles", "appointment_contributor_roles"); + + } + + /** + * 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_contributor_roles", "appointment_contributor_roles"); + + } + + /** + * Lists all available names. + * + * @return array + */ + 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::organizer => 0, + self::presenter => 1, + }; + + } + + /** + * Returns canonical string representation of object record status. + * + * @return string + */ + public function toString():string { + + return match($this) { + self::organizer => 'organizer', + self::presenter => 'presenter', + }; + + } + + /** + * 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_contributor_roles", "appointment_contributor_roles", $this->name); + + } + + /** + * Provides the option to serialize as a string during json_encode(). + * + * @return string + */ + public function jsonSerialize():string { + + return $this->name; + + } +}