diff --git a/l18n b/l18n index 7aae0b8..ca22b13 160000 --- a/l18n +++ b/l18n @@ -1 +1 @@ -Subproject commit 7aae0b8edbede8054e6d5e28c3a8a7dcc88734bd +Subproject commit ca22b133ecc12ad49b8d17519571cc2eb8a03df7 diff --git a/src/enums/MDObjectDamageStatus.php b/src/enums/MDObjectDamageStatus.php new file mode 100644 index 0000000..c556a7a --- /dev/null +++ b/src/enums/MDObjectDamageStatus.php @@ -0,0 +1,107 @@ + + */ +declare(strict_types = 1); + +/** + * Represents a type of status that can be assigned to an object in the process + * from identification to fixing or recognizing it is permanent. + */ +enum MDObjectDamageStatus implements MDValueEnumInterface, JsonSerializable { + + case identified; + case repair_possible; + case repair_scheduled; // By conservator + case repaired; + case irreparable; + + /** + * Returns a value of this type based on a string. + * + * @param string $input Input to get a value from. + * + * @return MDObjectDamageType + */ + public static function fromString(string $input):MDObjectDamageType { + + return match($input) { + 'identified' => self::identified, + 'repair_possible' => self::repair_possible, + 'repair_scheduled' => self::repair_scheduled, + 'repaired' => self::repaired, + 'irreparable' => self::irreparable, + default => throw new MDpageParameterNotFromListException("Unknown damage 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; + + } + + /** + * 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_damage_status_set", "object_damage_status_set"); + + } + + /** + * 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_damage_status_set", "object_damage_status_set"); + + } + + /** + * 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_damage_status_set", "object_damage_status_set", $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/MDObjectDamageType.php b/src/enums/MDObjectDamageType.php new file mode 100644 index 0000000..91a9466 --- /dev/null +++ b/src/enums/MDObjectDamageType.php @@ -0,0 +1,99 @@ + + */ +declare(strict_types = 1); + +/** + * Represents a type of damage an object may be subject to. + */ +enum MDObjectDamageType implements MDValueEnumInterface, JsonSerializable { + + case water_damage; + case breakage; + + /** + * Returns a value of this type based on a string. + * + * @param string $input Input to get a value from. + * + * @return MDObjectDamageType + */ + public static function fromString(string $input):MDObjectDamageType { + + return match($input) { + 'water_damage' => self::water_damage, + 'breakage' => self::breakage, + default => throw new MDpageParameterNotFromListException("Unknown damage 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; + + } + + /** + * 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_damage_types_set", "object_damage_types_set"); + + } + + /** + * 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_damage_types_set", "object_damage_types_set"); + + } + + /** + * 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_damage_types_set", "object_damage_types_set", $this->name); + + } + + /** + * Provides the option to serialize as a string during json_encode(). + * + * @return string + */ + public function jsonSerialize():string { + + return $this->name; + + } +}