diff --git a/l18n b/l18n index 8d83978..808895c 160000 --- a/l18n +++ b/l18n @@ -1 +1 @@ -Subproject commit 8d83978b4f1159445f16ed9bb15b791ea9a4724a +Subproject commit 808895ce187b34de591bbf7f4c1d9039a480e615 diff --git a/src/enums/MDInstitutionExternalIdRepository.php b/src/enums/MDInstitutionExternalIdRepository.php new file mode 100644 index 0000000..c00b442 --- /dev/null +++ b/src/enums/MDInstitutionExternalIdRepository.php @@ -0,0 +1,132 @@ + + */ +declare(strict_types = 1); + +/** + * Represents a possible status for to-dos. + */ +enum MDInstitutionExternalIdRepository implements MDValueEnumInterface, JsonSerializable { + + case hu_ksh; // https://en.wikipedia.org/wiki/Hungarian_Central_Statistical_Office + + const VALIDATION_PATTERN_HTML = [ + 'hu_ksh' => '[0-9]{8}-[0-9]{4}-[0-9]{3}-[0-9]{2}', + ]; + + const VALIDATION_PATTERN_PHP = [ + 'hu_ksh' => '[0-9]{8}-[0-9]{4}-[0-9]{3}-[0-9]{2}', + ]; + + /** + * Returns a value of this type based on a string. + * + * @param string $input Input to get a value from. + * + * @return MDInstitutionExternalIdRepository + */ + public static function fromString(string $input):MDInstitutionExternalIdRepository { + + return match($input) { + 'hu_ksh' => self::hu_ksh, + default => throw new MDpageParameterNotFromListException("Unknown external repository"), + }; + + } + + /** + * 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(), "institution_external_id_repositories", "institution_external_id_repositories"); + + } + + /** + * 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(), "institution_external_id_repositories", "institution_external_id_repositories"); + + } + + /** + * 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("institution_external_id_repositories", "institution_external_id_repositories", $this->name); + + } + + /** + * Returns the HTML pattern. + * + * @param MDTlLoader $tlLoader Translation loader. + * + * @return string + */ + public function getValidationPatternHtml():string { + + return self::VALIDATION_PATTERN_HTML[$this->name]; + + } + + /** + * Returns the PHP pattern. + * + * @param MDTlLoader $tlLoader Translation loader. + * + * @return string + */ + public function getValidationPatternPhp():string { + + return self::VALIDATION_PATTERN_PHP[$this->name]; + + } + + /** + * Provides the option to serialize as a string during json_encode(). + * + * @return string + */ + public function jsonSerialize():string { + + return $this->name; + + } +}