Support MDAppTokenSection::fromString()
This commit is contained in:
1 file changed
+19
@@ -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.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user