203 lines
5.3 KiB
PHP
203 lines
5.3 KiB
PHP
<?PHP
|
|
declare(strict_types = 1);
|
|
|
|
/**
|
|
* Represents a marking types.
|
|
*/
|
|
enum MDMarkingType implements MDValueEnumInterface, JsonSerializable {
|
|
|
|
case signature;
|
|
case engraving;
|
|
case watermark;
|
|
case scratch;
|
|
case stamp;
|
|
case overprint;
|
|
case embossing;
|
|
case handwritten;
|
|
case screwed;
|
|
case burnt_in;
|
|
case riveted;
|
|
case nailed;
|
|
case punched;
|
|
case hallmarked;
|
|
case scarified;
|
|
case cast;
|
|
case sewn;
|
|
case glued;
|
|
case painted;
|
|
case drawn;
|
|
case embroidered;
|
|
|
|
/**
|
|
* Returns a value of this type based on a string.
|
|
*
|
|
* @param string $input Input to get a value from.
|
|
*
|
|
* @return MDMarkingType
|
|
*/
|
|
public static function fromString(string $input):MDMarkingType {
|
|
|
|
return match($input) {
|
|
'signature' => self::signature,
|
|
'engraving' => self::engraving,
|
|
'watermark' => self::watermark,
|
|
'scratch' => self::scratch,
|
|
'stamp' => self::stamp,
|
|
'overprint' => self::overprint,
|
|
'embossing' => self::embossing,
|
|
'handwritten' => self::handwritten,
|
|
'screwed' => self::screwed,
|
|
'burnt_in' => self::burnt_in,
|
|
'riveted' => self::riveted,
|
|
'nailed' => self::nailed,
|
|
'punched' => self::punched,
|
|
'hallmarked' => self::hallmarked,
|
|
'scarified' => self::scarified,
|
|
'cast' => self::cast,
|
|
'sewn' => self::sewn,
|
|
'glued' => self::glued,
|
|
'painted' => self::painted,
|
|
'drawn' => self::drawn,
|
|
'embroidered' => self::embroidered,
|
|
default => throw new MDpageParameterNotFromListException("Unknown marking type"),
|
|
};
|
|
|
|
}
|
|
|
|
/**
|
|
* Returns a value of this type based on an integer.
|
|
*
|
|
* @param integer $input Input to get a value from.
|
|
*
|
|
* @return MDMarkingType
|
|
*/
|
|
public static function fromInt(int $input):MDMarkingType {
|
|
|
|
return match($input) {
|
|
1 => self::signature,
|
|
2 => self::engraving,
|
|
3 => self::watermark,
|
|
4 => self::scratch,
|
|
5 => self::stamp,
|
|
6 => self::overprint,
|
|
7 => self::embossing,
|
|
8 => self::handwritten,
|
|
9 => self::screwed,
|
|
10 => self::burnt_in,
|
|
11 => self::riveted,
|
|
12 => self::nailed,
|
|
13 => self::punched,
|
|
14 => self::hallmarked,
|
|
15 => self::scarified,
|
|
16 => self::cast,
|
|
17 => self::sewn,
|
|
18 => self::glued,
|
|
19 => self::painted,
|
|
20 => self::drawn,
|
|
21 => self::embroidered,
|
|
default => throw new MDpageParameterNotFromListException("Unknown marking 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::signature => 1,
|
|
self::engraving => 2,
|
|
self::watermark => 3,
|
|
self::scratch => 4,
|
|
self::stamp => 5,
|
|
self::overprint => 6,
|
|
self::embossing => 7,
|
|
self::handwritten => 8,
|
|
self::screwed => 9,
|
|
self::burnt_in => 10,
|
|
self::riveted => 11,
|
|
self::nailed => 12,
|
|
self::punched => 13,
|
|
self::hallmarked => 14,
|
|
self::scarified => 15,
|
|
self::cast => 16,
|
|
self::sewn => 17,
|
|
self::glued => 18,
|
|
self::painted => 19,
|
|
self::drawn => 20,
|
|
self::embroidered => 21,
|
|
# 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(), "marking_types", "marking_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(), "marking_types", "marking_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("marking_types", "marking_types", $this->name);
|
|
|
|
}
|
|
|
|
/**
|
|
* Provides the option to serialize as a string during json_encode().
|
|
*
|
|
* @return string
|
|
*/
|
|
public function jsonSerialize():string {
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
}
|