Add enum MDUserAccountAction enumerating actions that accounts may be
put under externally
This commit is contained in:
parent
49f78e24b4
commit
eab910b704
51
src/enums/MDUserAccountAction.php
Normal file
51
src/enums/MDUserAccountAction.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Lists the types of external conditions put upon user accounts in the md context.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
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<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user