Add MDTimingInterval for controlling intervals at which (for now)

autogenerated reports can be timed in musdb
This commit is contained in:
Joshua Ramon Enslin 2023-01-03 01:33:16 +01:00
parent 663edea4db
commit be01725a6f
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
2 changed files with 102 additions and 1 deletions

2
l18n

@ -1 +1 @@
Subproject commit 69d86e4bf56528e9e1ddc8e4330a9f7c0b3d4880
Subproject commit 8313264c585b13440f67b5922b918ba8198d24a5

View File

@ -0,0 +1,101 @@
<?PHP
/**
* Represents timing intervals for autogenerated exports etc.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Represents timing intervals for autogenerated exports etc.
*/
enum MDTimingInternal implements MDValueEnumInterface, JsonSerializable {
case weekly;
case monthly;
case annual;
/**
* Returns a value of this type based on a string.
*
* @param string $input Input to get a value from.
*
* @return MDTimingInternal
*/
public static function fromString(string $input):MDTimingInternal {
return match($input) {
'weekly' => self::weekly,
'monthly' => self::weekly,
'annual' => self::weekly,
default => throw new MDpageParameterNotFromListException("Unknown timing interval: " . $input),
};
}
/**
* 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;
}
/**
* 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(), "timing_intervals_set", "timing_intervals_set");
}
/**
* 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(), "timing_intervals_set", "timing_intervals_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("timing_intervals_set", "timing_intervals_set", $this->name);
}
/**
* Provides the option to serialize as a string during json_encode().
*
* @return string
*/
public function jsonSerialize():string {
return $this->name;
}
}