2e6e7e2c53
Close #40
148 lines
4.0 KiB
PHP
148 lines
4.0 KiB
PHP
<?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;
|
|
case reviewed;
|
|
|
|
/**
|
|
* 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,
|
|
'reviewed' => self::reviewed,
|
|
default => throw new MDpageParameterNotFromListException("Unknown transcript status"),
|
|
};
|
|
|
|
}
|
|
|
|
/**
|
|
* Returns a value of this status based on an integer.
|
|
*
|
|
* @param integer $input Input to get a value from.
|
|
*
|
|
* @return MDTranscriptionStatus
|
|
*/
|
|
public static function fromInt(int $input):MDTranscriptionStatus {
|
|
|
|
return match($input) {
|
|
1 => self::incomplete,
|
|
2 => self::machine_generated,
|
|
3 => self::rough_draft,
|
|
4 => self::quality_control_failed,
|
|
5 => self::quality_control_passed,
|
|
6 => self::reviewed,
|
|
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,
|
|
self::reviewed => 6,
|
|
# default => throw new MDpageParameterNotFromListException("Unknown transcription 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;
|
|
|
|
}
|
|
}
|