PHP Classes
elePHPant
Icontem

PHP Enum Const: Provide enumerated values using class constants

Recommend this page to a friend!
  Info   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2014-03-13 (2 years ago) RSS 2.0 feedNot enough user ratingsTotal: 212 All time: 7,731 This week: 916Up
Version License PHP version Categories
php-enum-const 1.0Freely Distributable5.3PHP 5, Data types
Description Author

This class can provide enumerated values using class constants.

It provides a base class that should be extended by a class that defines the enumerated values as class constants.

The class can set or get the complete list of supported enumerated constants, return the enumerated name as an object string value, as well the respective value using the getValue function.

Innovation Award
PHP Programming Innovation award winner
March 2014
Winner


Prize: One book of choice by Packt
Enumerated types are often used to pass values that must be set to a certain set of values.

This class implements enumerated types by using reflection to get the constants of a class and use their values to define the set of accepted values of an enumerated type.

This way developers only need to define the class constants to determine which are the values accepted in the enumerated type.

Using classes as enumerated values also makes it easy to benefit from type hinting to validate the types of values passed to functions that takes enumerated types as parameters.

Manuel Lemos
Picture of Ahmed Magdy Ezzeldin
  Performance   Level  
Name: Ahmed Magdy Ezzeldin <contact>
Classes: 4 packages by
Country: Egypt Egypt
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

  Files folder image Files  
File Role Description
Accessible without login Plain text file Enum.php Class Include the enum class in your code to use it
Accessible without login Plain text file EnumTest.php Example Example Script
Accessible without login Plain text file License Lic. Apache License v2.0

 Version Control Unique User Downloads Download Rankings  
 0%
Total:212
This week:0
All time:7,731
This week:916Up