diff --git a/l18n b/l18n index 0be5ccf..b032391 160000 --- a/l18n +++ b/l18n @@ -1 +1 @@ -Subproject commit 0be5ccf2d443c047677e50281ef820db9c35b83d +Subproject commit b032391f23155f8c57a03ba3522b580f4b8e8759 diff --git a/src/enums/MDTranscriptionStatus.php b/src/enums/MDTranscriptionStatus.php new file mode 100644 index 0000000..a0fbe6f --- /dev/null +++ b/src/enums/MDTranscriptionStatus.php @@ -0,0 +1,143 @@ + + */ +declare(strict_types = 1); + +/** + * Represents a type of check an object may be subject to (completeness, condition, general audit). + */ +enum MDTranscriptionStatus implements MDValueEnumInterface, JsonSerializable { + + case incomplete; + case machine_generated; + case rough_draft; + case quality_control_failed; + case quality_control_passed; + + /** + * Returns a value of this type based on a string. + * + * @param string $input Input to get a value from. + * + * @return MDTranscriptionStatus + */ + public static function fromString(string $input):MDTranscriptionStatus { + + return match($input) { + 'incomplete' => self::incomplete, + 'machine_generated' => self::machine_generated, + 'rough_draft' => self::rough_draft, + 'quality_control_failed' => self::quality_control_failed, + 'quality_control_passed' => self::quality_control_passed, + default => throw new MDpageParameterNotFromListException("Unknown transcript status"), + }; + + } + + /** + * Returns a value of this type based on an integer. + * + * @param integer $input Input to get a value from. + * + * @return MDMeasurementType + */ + public static function fromInt(int $input):MDMeasurementType { + + return match($input) { + 1 => self::incomplete, + 2 => self::machine_generated, + 3 => self::rough_draft, + 4 => self::quality_control_failed, + 5 => self::quality_control_passed, + default => throw new MDpageParameterNotFromListException("Unknown transcript status"), + }; + + } + + /** + * Lists all available names. + * + * @return array + */ + public static function caseNames():array { + + $output = []; + + $cases = self::cases(); + foreach ($cases as $case) { + $output[] = $case->name; + } + + return $output; + + } + + /** + * Returns an integer representation of the collective (for storage in DB). + * + * @return integer + */ + public function toInt():int { + + return match($this) { + self::incomplete => 1, + self::machine_generated => 2, + self::rough_draft => 3, + self::quality_control_failed => 4, + self::quality_control_passed => 5, + # default => throw new MDpageParameterNotFromListException("Unknown measurement type"), + }; + + } + + /** + * 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(), "transcript_status", "transcript_status"); + + } + + /** + * 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(), "transcript_status", "transcript_status"); + + } + + /** + * 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("transcript_status", "transcript_status", $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/MDTranscriptionType.php b/src/enums/MDTranscriptionType.php new file mode 100644 index 0000000..9943c2f --- /dev/null +++ b/src/enums/MDTranscriptionType.php @@ -0,0 +1,143 @@ + + */ +declare(strict_types = 1); + +/** + * Represents a type a transcription was generated towards. + */ +enum MDTranscriptionType implements MDValueEnumInterface, JsonSerializable { + + case simple_transcription; + case diplomatic_transcription; + case critical_edition; + case historical_critical_edition; + case reading_edition; + + /** + * Returns a value of this type based on a string. + * + * @param string $input Input to get a value from. + * + * @return MDTranscriptionType + */ + public static function fromString(string $input):MDTranscriptionType { + + return match($input) { + 'simple_transcription' => self::simple_transcription, + 'diplomatic_transcription' => self::diplomatic_transcription, + 'critical_edition' => self::critical_edition, + 'historical_critical_edition' => self::historical_critical_edition, + 'reading_edition' => self::reading_edition, + default => throw new MDpageParameterNotFromListException("Unknown transcription type"), + }; + + } + + /** + * Returns a value of this type based on an integer. + * + * @param integer $input Input to get a value from. + * + * @return MDMeasurementType + */ + public static function fromInt(int $input):MDMeasurementType { + + return match($input) { + 1 => self::simple_transcription, + 2 => self::diplomatic_transcription, + 3 => self::critical_edition, + 4 => self::historical_critical_edition, + 5 => self::reading_edition, + default => throw new MDpageParameterNotFromListException("Unknown transcript type"), + }; + + } + + /** + * Lists all available names. + * + * @return array + */ + public static function caseNames():array { + + $output = []; + + $cases = self::cases(); + foreach ($cases as $case) { + $output[] = $case->name; + } + + return $output; + + } + + /** + * Returns an integer representation of the collective (for storage in DB). + * + * @return integer + */ + public function toInt():int { + + return match($this) { + self::simple_transcription => 1, + self::diplomatic_transcription => 2, + self::critical_edition => 3, + self::historical_critical_edition => 4, + self::reading_edition => 5, + # default => throw new MDpageParameterNotFromListException("Unknown measurement type"), + }; + + } + + /** + * 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(), "transcript_types", "transcript_types"); + + } + + /** + * 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(), "transcript_types", "transcript_types"); + + } + + /** + * 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("transcript_types", "transcript_types", $this->name); + + } + + /** + * Provides the option to serialize as a string during json_encode(). + * + * @return string + */ + public function jsonSerialize():string { + + return $this->name; + + } +}