From eab910b7047d3a29ccee8e1654191f38a7a49c72 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Mon, 13 Feb 2023 17:36:10 +0100 Subject: [PATCH] Add enum MDUserAccountAction enumerating actions that accounts may be put under externally --- src/enums/MDUserAccountAction.php | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/enums/MDUserAccountAction.php diff --git a/src/enums/MDUserAccountAction.php b/src/enums/MDUserAccountAction.php new file mode 100644 index 0000000..993a0f0 --- /dev/null +++ b/src/enums/MDUserAccountAction.php @@ -0,0 +1,51 @@ + + */ +declare(strict_types = 1); + +/** + * Lists the types of external conditions put upon user accounts in the md context. + */ +enum MDUserAccountAction { + + case none; + case email_reconfirmation_required; + + /** + * Returns a value of this type based on a string. + * + * @param string $input Input to get a value from. + * + * @return MDUserAccountAction + */ + public static function fromString(string $input):MDUserAccountAction { + + return match($input) { + 'none' => self::none, + 'email_reconfirmation_required' => self::email_reconfirmation_required, + default => throw new MDpageParameterNotFromListException("Unknown user account action"), + }; + + } + + /** + * Lists all available names. + * + * @return array + */ + public static function caseNames():array { + + $output = []; + + $cases = self::cases(); + foreach ($cases as $case) { + $output[] = $case->name; + } + + return $output; + + } +}