Class Xyster_Enum

Description

Enumerable type object

PHP contains no enum-type class internally, so to mirror the convenience such a class offers, we created the Xyster_Enum. Enum classes are used to represent set types of things, for instance, if we created a class to represent different operating systems, it might provide enum methods like this:

  1.  $unix OperatingSystem::Unix();
  2.  $win OperatingSystem::Windows();
  3.  $mac OperatingSystem::Mac();
  4.  echo $unix->getName()// prints Unix

  • copyright: Copyright (c) 2007-2008 Irrational Logic (http://irrationallogic.net)
  • abstract:
  • license: New BSD License

Located in /Enum.php (line 42)


	
			
Direct descendents
Class Description
Xyster_Data_Aggregate Aggregate function enumerated type
Xyster_Data_Operator_Expression Enumerated type of Expression operators
Xyster_Db_DataType SQL Data type enumerated type
Xyster_Db_ReferentialAction SQL referential action enumerated type
Method Summary
static Xyster_Enum parse (string $className, string $name)
static Xyster_Enum valueOf (string $className, string $value)
static array values (string $className)
static Xyster_Enum _factory ([string $className = null], [mixed $name = null])
Xyster_Enum __construct (string $name, mixed $value)
string getName ()
mixed getValue ()
void __clone ()
string __toString ()
Methods
static method parse (line 127)

Returns the corresponding enum object based on name

  1.  $color Xyster_Enum::parse('Colors','red')// name is case insensitive

  • return: Translated object
  • throws: Exception if $name was not found in $className
  • access: public
static Xyster_Enum parse (string $className, string $name)
  • string $className: Name of the Xyster_Enum-derived class to instantiate
  • string $name: Name to parse
static method valueOf (line 148)

Returns the corresponding enum object based on value

  1.  $color Xyster_Enum::valueOf('Colors',0);

  • return: Translated object
  • throws: Exception if $className isn't derived from Xyster_Enum
  • access: public
static Xyster_Enum valueOf (string $className, string $value)
  • string $className: Name of the Xyster_Enum-derived class to instantiate
  • string $value: Value to parse
static method values (line 170)

Gets an array of the name and value pairs available from an enum

The associative array contains the enum values as keys and the enum constant names as values. For example, the Colors enum might return:

  1.  return array0=>'Red'1=>'Orange'2=>'Yellow'3=>'Green' );

  • throws: Exception if $className isn't derived from Xyster_Enum
  • access: public
static array values (string $className)
  • string $className
static method _factory (line 187)

Factories and returns a singleton enum

  • access: protected
static Xyster_Enum _factory ([string $className = null], [mixed $name = null])
  • string $className
  • mixed $name
Constructor __construct (line 70)

Creates a new enum derived class

  • access: protected
Xyster_Enum __construct (string $name, mixed $value)
  • string $name: Enum name
  • mixed $value: Enum value
getName (line 91)

Gets the string name of this enum type

  • return: Name of this enum
  • access: public
string getName ()
getValue (line 100)

Gets the value of this enum type

  • return: Value of this enum
  • access: public
mixed getValue ()
__clone (line 81)

Cannot be cloned

  • magic:
  • access: public
void __clone ()
__toString (line 110)

Gets details of the object

  • return: Details of object
  • magic:
  • access: public
string __toString ()

Documentation generated on Mon, 19 May 2008 17:07:07 -0400 by phpDocumentor 1.4.2