*/ declare(strict_types = 1); /** * Represents a type of link between tag and object (e.g. the tag being the object * type, a material used for creating the object, etc.). */ enum MDObjectRecordStatus implements MDValueEnumInterface, JsonSerializable { case unlocked; case locked; case revision; case deleted; /** * Returns a value of this type based on a string. * * @param string $input Input to get a value from. * * @return MDObjectRecordStatus */ public static function fromString(string $input):MDTagRelationType { return match($input) { 'unlocked' => self::unlocked, 'locked' => self::locked, 'revision' => self::revision, 'deleted' => self::deleted, default => throw new MDpageParameterNotFromListException("Unknown object record status"), }; } /** * Returns a value of this type based on an integer. * * @param integer $input Input to get a value from. * * @return MDObjectRecordStatus */ public static function fromInt(int $input):MDTagRelationType { return match($input) { 0 => self::unlocked, 1 => self::locked, 2 => self::revision, 3 => self::deleted, default => throw new MDpageParameterNotFromListException("Unknown object record status"), }; } /** * Returns the default status. * * @return MDObjectRecordStatus */ public static function getDefault():MDTagRelationType { return self::unlocked; } /** * Lists all available names. * * @return array */ public static function caseNames():array { $output = []; $cases = self::cases(); foreach ($cases as $case) { $output[] = $case->name; } return $output; } /** * 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 tag relations. * * @return integer */ public function toInt():int { return match($this) { self::unlocked => 0, self::locked => 1, self::revision > 2, self::deleted => 3, // default => throw new MDpageParameterNotFromListException("Unknown tag relation 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(), "object_record_status", "object_record_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(), "object_record_status", "object_record_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("object_record_status", "object_record_status", $this->name); } /** * Provides the option to serialize as a string during json_encode(). * * @return string */ public function jsonSerialize():string { return $this->name; } }