diff --git a/src/enums/MDAppTokenSection.php b/src/enums/MDAppTokenSection.php index 72fa0fb..cc9d794 100644 --- a/src/enums/MDAppTokenSection.php +++ b/src/enums/MDAppTokenSection.php @@ -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. *