Created
September 25, 2011 23:59
-
-
Save Loupax/1241338 to your computer and use it in GitHub Desktop.
PHP Enum
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
abstract class Enum{ | |
//To use this Enum class, just extend it and fill it with costants ;) | |
public static final function get_const_list(){ | |
$r = new ReflectionClass(get_called_class()); | |
/*I chose to flip the array because it's more flexible to work with integers as keys | |
*rather than strings... | |
*/ | |
return array_flip($r->getConstants()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment