Add transcript status and type
This commit is contained in:
2
l18n
2
l18n
Submodule l18n updated: 0be5ccf2d4...b032391f23
143
src/enums/MDTranscriptionStatus.php
Normal file
143
src/enums/MDTranscriptionStatus.php
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
<?PHP
|
||||||
|
/**
|
||||||
|
* Represents a type of check an object may be subject to (completeness, condition, general audit).
|
||||||
|
*
|
||||||
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||||
|
*/
|
||||||
|
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<string>
|
||||||
|
*/
|
||||||
|
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<string, string>
|
||||||
|
*/
|
||||||
|
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<string, string>
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
143
src/enums/MDTranscriptionType.php
Normal file
143
src/enums/MDTranscriptionType.php
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
<?PHP
|
||||||
|
/**
|
||||||
|
* Represents a type a transcription was generated towards.
|
||||||
|
*
|
||||||
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||||
|
*/
|
||||||
|
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<string>
|
||||||
|
*/
|
||||||
|
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<string, string>
|
||||||
|
*/
|
||||||
|
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<string, string>
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user