diff --git a/l18n b/l18n index 2ebad2f..c154279 160000 --- a/l18n +++ b/l18n @@ -1 +1 @@ -Subproject commit 2ebad2f0e12af57cf326e94129b01ffaf5707b39 +Subproject commit c154279255a9e6dc1d0a79aea7eb286c5d0fcd14 diff --git a/src/enums/MDAppointmentContributorRole.php b/src/enums/MDAppointmentContributorRole.php index b4a6bcd..1d28c27 100644 --- a/src/enums/MDAppointmentContributorRole.php +++ b/src/enums/MDAppointmentContributorRole.php @@ -109,7 +109,7 @@ enum MDAppointmentContributorRole implements MDValueEnumInterface, JsonSerializa } /** - * Returns integer representation of object record status. + * Returns integer representation of appointment status. * * @return integer */ @@ -123,7 +123,7 @@ enum MDAppointmentContributorRole implements MDValueEnumInterface, JsonSerializa } /** - * Returns canonical string representation of object record status. + * Returns canonical string representation of appointment status. * * @return string */ diff --git a/src/enums/MDSourceContributorRole.php b/src/enums/MDSourceContributorRole.php new file mode 100644 index 0000000..0c4f0ff --- /dev/null +++ b/src/enums/MDSourceContributorRole.php @@ -0,0 +1,157 @@ + self::author, + "editor" => self::editor, + default => throw new MDpageParameterNotFromListException("Unknown source contributor role"), + }; + + } + + /** + * Returns a value of this type based on an integer. + * + * @param integer $input Input to get a value from. + * + * @return MDSourceContributorRole + */ + public static function fromInt(int $input):MDSourceContributorRole { + + return match($input) { + 0 => self::author, + 1 => self::editor, + default => throw new MDpageParameterNotFromListException("Unknown source 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(), "source_contributor_roles", "source_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(), "source_contributor_roles", "source_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 source contributor status. + * + * @return integer + */ + public function toInt():int { + + return match($this) { + self::author => 0, + self::editor => 1, + }; + + } + + /** + * Returns canonical string representation of source contributor status. + * + * @return string + */ + public function toString():string { + + return match($this) { + self::author => 'author', + self::editor => 'editor', + }; + + } + + /** + * 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("source_contributor_roles", "source_contributor_roles", $this->name); + + } + + /** + * Provides the option to serialize as a string during json_encode(). + * + * @return string + */ + public function jsonSerialize():string { + + return $this->name; + + } +}