Login   Register  
PHP Classes
elePHPant
Icontem

Typesafe Enum: Implement enumerated values as class functions

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2010-07-07 (4 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 373 All time: 6,091 This week: 1,504Up
Version License PHP version Categories  
typesafe-enum 1.1BSD License5.2.5PHP 5, Data types, Code Generation
Description Author  

This class can be used to implement enumerated values as class functions.

It takes the name of a class and the list of names for enumerated values to define and generates code for a new class that defines the enumerated values.

The enumerated values can be retrieved using static function calls to the generated class.

Innovation Award  
PHP Programming Innovation award nominee
March 2010
Number 5


Prize: One book of choice by Packt
Enumerated values can be used to assign meaningful values to variables that only accept a limited number of values.

An alternative way to implement enumerated value types by using class functions to represent each enumerated value.

Manuel Lemos
Picture of Fabian Schmengler
Name: Fabian Schmengler is available for providing paid consulting. Contact Fabian Schmengler .
Classes: 5 packages by
Country: Germany Germany
Age: 31
All time rank: 114873 in Germany Germany
Week rank: 812 Up35 in Germany Germany Up
Innovation award
Innovation award
Nominee: 4x

  Files folder image Files  
File Role Description
Files folder imageexample (1 file)
Files folder imagetest (3 files)
Files folder imagecache (1 file)
Accessible without login Plain text file readme.txt Doc. Full documentation
Plain text file license.txt Lic. BSD License
Plain text file typesafeenum.lib.php Aux. Include this file to use the package
Plain text file Enum.php Class Enum base class and generator

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file example.php Example Simple example usage

  Files folder image Files  /  test  
File Role Description
  Plain text file EnumBenchmark.php Class Benchmark class
  Plain text file EnumTest.php Test PHPUnit test class
  Plain text file run_benchmark.php Aux. The script that I used for benchmarking

  Files folder image Files  /  cache  
File Role Description
  Plain text file EMPTY Data make this directory writable for PHP

 Version Control Reuses Unique User Downloads Download Rankings  
 0%1Total:373All time:6,091
 This week:0This week:1,504Up
 User Comments (1)