\MyCLabs\EnumEnum

Base Enum class

Create an enum by implementing this class and adding class constants.

Summary

Methods
Properties
Constants
__construct()
getValue()
getKey()
__toString()
equals()
keys()
values()
toArray()
isValid()
isValidKey()
search()
__callStatic()
jsonSerialize()
No public properties found
No constants found
No protected methods found
$value
$cache
N/A
No private methods found
No private properties found
N/A

Properties

$value

$value : mixed

Enum value

Type

mixed

$cache

$cache : array

Store existing constants in a static cache per object.

Type

array

Methods

__construct()

__construct(mixed  $value) 

Creates a new value of some type

Parameters

mixed $value

Throws

\UnexpectedValueException

if incompatible type is given.

getValue()

getValue() : mixed

Returns

mixed

getKey()

getKey() : mixed

Returns the enum key (i.e. the constant name).

Returns

mixed

__toString()

__toString() : string

Returns

string

equals()

equals(  $variable = null) : boolean

Determines if Enum should be considered equal with the variable passed as a parameter.

Returns false if an argument is an object of different class or not an object.

This method is final, for more information read https://github.com/myclabs/php-enum/issues/4

Parameters

$variable

Returns

boolean

keys()

keys() : array

Returns the names (keys) of all constants in the Enum class

Returns

array

values()

values() : array<mixed,static>

Returns instances of the Enum class of all Enum constants

Returns

array<mixed,static> —

Constant name in key, Enum instance in value

toArray()

toArray() : array

Returns all possible values as an array

Returns

array —

Constant name in key, constant value in value

isValid()

isValid(  $value) : boolean

Check if is valid enum value

Parameters

$value

Returns

boolean

isValidKey()

isValidKey(  $key) : boolean

Check if is valid enum key

Parameters

$key

Returns

boolean

search()

search(  $value) : mixed

Return key for value

Parameters

$value

Returns

mixed

__callStatic()

__callStatic(string  $name, array  $arguments) : static

Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a class constant

Parameters

string $name
array $arguments

Throws

\BadMethodCallException

Returns

static

jsonSerialize()

jsonSerialize() : mixed

Specify data which should be serialized to JSON. This method returns data that can be serialized by json_encode() natively.

Returns

mixed