self::ASC, 'ASC' => self::ASC, 'desc' => self::DESC, 'DESC' => self::DESC, default => throw new MDpageParameterNotFromListException("Unknown sort order"), }; } /** * Returns a value of this type based on an integer. * * @param integer $input Input to get a value from. * * @return MDDbQueryAscDesc */ public static function fromInt(int $input):MDDbQueryAscDesc { return match($input) { 1 => self::ASC, 2 => self::DESC, default => throw new MDpageParameterNotFromListException("Unknown sort order"), }; } /** * */ /** * Lists all available names. * * @return array */ 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::ASC => 1, self::DESC => 2, # default => throw new MDpageParameterNotFromListException("Unknown measurement type"), }; } /** * Returns the SQL representation of the entity. * * @return string */ public function toDbName():string { return match ($this) { self::ASC => 'ASC', self::DESC => 'DESC', }; } /** * 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(), "query_asc_desc", "query_asc_desc"); } /** * 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(), "query_asc_desc", "query_asc_desc"); } /** * 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("query_asc_desc", "query_asc_desc", $this->name); } /** * Provides the option to serialize as a string during json_encode(). * * @return string */ public function jsonSerialize():string { return $this->name; } }