From fc189763055ab3e2773265efcb33830f06d0846c Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Sun, 1 Nov 2026 14:20:45 +0100 Subject: [PATCH] Support MDAppTokenSection::fromString() --- src/enums/MDAppTokenSection.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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. *