Support MDAppTokenSection::fromString()

This commit is contained in:
jrenslin committed 2026-11-01 14:20:45 +01:00
1 parent 12992a7384
commit fc18976305
1 file changed
+19
+19
View File
@@ -17,6 +17,25 @@ enum MDAppTokenSection {
case space_sensors_dashboard;
case general_stats_dashboard;
/**
* Returns a value of this type based on a string.
*
* @param string $input Input to get a value from.
*
* @return MDAppTokenSection
*/
public static function fromString(string $input):MDAppTokenSection {
return match($input) {
'webcal' => self::webcal,
'space_sensors' => self::space_sensors,
'space_sensors_dashboard' => self::space_sensors_dashboard,
'general_stats_dashboard' => self::general_stats_dashboard,
default => throw new MDpageParameterNotFromListException("Unknown app token type"),
};
}
/**
* Lists all available names.
*