PHP Class MabeEnum\Enum

Datei anzeigen Open project: marc-mabe/php-enum Class Usage Examples

Public Methods

Method Description
__callStatic ( string $method, array $args ) : static Get an enumerator instance by the given name.
__sleep ( )
__toString ( ) : string Get the name of the enumerator
__wakeup ( )
clear ( ) : void Clear all instantiated enumerators of the called class
get ( static | null | boolean | integer | float | string $value ) : static Get an enumerator instance of the given value or instance
getByName ( string $name ) : static Get an enumerator instance by the given name
getByOrdinal ( integer $ordinal ) : static Get an enumeration instance by the given ordinal number
getConstants ( ) : array Get all available constants of the called class
getEnumerators ( ) : static[] Get a list of enumerator instances ordered by ordinal number
getName ( ) : string Get the name of the enumerator
getOrdinal ( ) : integer Get the ordinal number of the enumerator
getValue ( ) : null | boolean | integer | float | string Get the value of the enumerator
has ( static | null | boolean | integer | float | string $value ) : boolean Is the given enumerator part of this enumeration
is ( mixed $enumerator ) : boolean Compare this enumerator against another and check if it's the same.

Private Methods

Method Description
__clone ( )
__construct ( null | boolean | integer | float | string $value, integer | null $ordinal = null ) Constructor
detectConstants ( string $class ) : array Detect all available constants by the given class

Method Details

__callStatic() final public static method

This will be called automatically on calling a method with the same name of a defined enumerator.
final public static __callStatic ( string $method, array $args ) : static
$method string The name of the enumeraotr (called as method)
$args array There should be no arguments
return static

__sleep() final public method

final public __sleep ( )

__toString() public method

Get the name of the enumerator
See also: getName()
public __toString ( ) : string
return string

__wakeup() final public method

final public __wakeup ( )

clear() final public static method

NOTE: This can break singleton behavior ... use it with caution!
final public static clear ( ) : void
return void

get() final public static method

Get an enumerator instance of the given value or instance
final public static get ( static | null | boolean | integer | float | string $value ) : static
$value static | null | boolean | integer | float | string
return static

getByName() final public static method

Get an enumerator instance by the given name
final public static getByName ( string $name ) : static
$name string The name of the enumerator
return static

getByOrdinal() final public static method

Get an enumeration instance by the given ordinal number
final public static getByOrdinal ( integer $ordinal ) : static
$ordinal integer The ordinal number or the enumerator
return static

getConstants() final public static method

Get all available constants of the called class
final public static getConstants ( ) : array
return array

getEnumerators() final public static method

Get a list of enumerator instances ordered by ordinal number
final public static getEnumerators ( ) : static[]
return static[]

getName() final public method

Get the name of the enumerator
final public getName ( ) : string
return string

getOrdinal() final public method

Get the ordinal number of the enumerator
final public getOrdinal ( ) : integer
return integer

getValue() final public method

Get the value of the enumerator
final public getValue ( ) : null | boolean | integer | float | string
return null | boolean | integer | float | string

has() final public static method

Is the given enumerator part of this enumeration
final public static has ( static | null | boolean | integer | float | string $value ) : boolean
$value static | null | boolean | integer | float | string
return boolean

is() final public method

Compare this enumerator against another and check if it's the same.
final public is ( mixed $enumerator ) : boolean
$enumerator mixed
return boolean