Skip to content

Instantly share code, notes, and snippets.

@Loupax
Created September 25, 2011 23:59
Show Gist options
  • Save Loupax/1241338 to your computer and use it in GitHub Desktop.
Save Loupax/1241338 to your computer and use it in GitHub Desktop.
PHP Enum
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