\DASPRiD\EnumAbstractEnum

Summary

Methods
Properties
Constants
__callStatic()
valueOf()
values()
name()
ordinal()
compareTo()
__clone()
__sleep()
__wakeup()
__toString()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
__construct()
createValue()
constants()
$name
$ordinal
$values
$allValuesLoaded
$constants
N/A

Properties

$name

$name : string

Type

string

$ordinal

$ordinal : int

Type

int

$values

$values : array<string,array<string,static>>

Type

array>

$allValuesLoaded

$allValuesLoaded : array<string,bool>

Type

array

$constants

$constants : array<string,array>

Type

array

Methods

__callStatic()

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

Magic getter which forwards all calls to {@see self::valueOf()}.

Parameters

string $name
array $arguments

Returns

static —

valueOf()

valueOf(string  $name) : static

Returns an enum with the specified name.

The name must match exactly an identifier used to declare an enum in this type (extraneous whitespace characters are not permitted).

Parameters

string $name

Throws

\DASPRiD\Enum\Exception\IllegalArgumentException

if the enum has no constant with the specified name

Returns

static —

values()

values() : static[]

Obtains all possible types defined by this enum.

Returns

static[] —

name()

name() : string

Returns the name of this enum constant, exactly as declared in its enum declaration.

Most programmers should use the {@see \DASPRiD\Enum\self::__toString()} method in preference to this one, as the toString method may return a more user-friendly name. This method is designed primarily for use in specialized situations where correctness depends on getting the exact name, which will not vary from release to release.

Returns

string —

ordinal()

ordinal() : int

Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero).

Most programmers will have no use for this method. It is designed for use by sophisticated enum-based data structures.

Returns

int —

compareTo()

compareTo(self  $other) : int

Compares this enum with the specified object for order.

Returns negative integer, zero or positive integer as this object is less than, equal to or greater than the specified object.

Enums are only comparable to other enums of the same type. The natural order implemented by this method is the order in which the constants are declared.

Parameters

self $other

Throws

\DASPRiD\Enum\Exception\MismatchException

if the passed enum is not of the same type

Returns

int —

__clone()

__clone() : mixed

Forbid cloning enums.

Throws

\DASPRiD\Enum\Exception\CloneNotSupportedException

Returns

mixed —

__sleep()

__sleep() : array

Forbid serializing enums.

Throws

\DASPRiD\Enum\Exception\SerializeNotSupportedException

Returns

array —

__wakeup()

__wakeup() : void

Forbid unserializing enums.

Throws

\DASPRiD\Enum\Exception\UnserializeNotSupportedException

__toString()

__toString() : string

Turns the enum into a string representation.

You may override this method to give a more user-friendly version.

Returns

string —

__construct()

__construct() : mixed

The constructor is private by default to avoid arbitrary enum creation.

When creating your own constructor for a parameterized enum, make sure to declare it as protected, so that the static methods are able to construct it. Avoid making it public, as that would allow creation of non-singleton enum instances.

Returns

mixed —

createValue()

createValue(string  $name, int  $ordinal, array  $arguments) : static

Parameters

string $name
int $ordinal
array $arguments

Returns

static —

constants()

constants() : array

Returns

array —