Created
February 9, 2022 08:11
-
-
Save the-toster/180eace28fb1407ff2001587f93e27a6 to your computer and use it in GitHub Desktop.
Instantiate eunm by name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function enumByName(string $enumClass, string $case): object { | |
return (new \ReflectionEnum($enumClass))->getCase($case)->getValue(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment