PHP Класс MyCLabs\Enum\Enum

Create an enum by implementing this class and adding class constants.
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$cache array Store existing constants in a static cache per object.
$value mixed Enum value

Открытые методы

Метод Описание
__callStatic ( string $name, array $arguments ) : static Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a class constant
__construct ( mixed $value ) Creates a new value of some type
__toString ( ) : string
equals ( Enum $enum ) : boolean Compares one Enum with another.
getKey ( ) : mixed Returns the enum key (i.e. the constant name).
getValue ( ) : mixed
isValid ( $value ) : boolean Check if is valid enum value
isValidKey ( $key ) : boolean Check if is valid enum key
keys ( ) : array Returns the names (keys) of all constants in the Enum class
search ( $value ) : mixed Return key for value
toArray ( ) : array Returns all possible values as an array
values ( ) : static[] Returns instances of the Enum class of all Enum constants

Описание методов

__callStatic() публичный статический Метод

Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a class constant
public static __callStatic ( string $name, array $arguments ) : static
$name string
$arguments array
Результат static

__construct() публичный Метод

Creates a new value of some type
public __construct ( mixed $value )
$value mixed

__toString() публичный Метод

public __toString ( ) : string
Результат string

equals() закрытый публичный Метод

This method is final, for more information read https://github.com/myclabs/php-enum/issues/4
final public equals ( Enum $enum ) : boolean
$enum Enum
Результат boolean True if Enums are equal, false if not equal

getKey() публичный Метод

Returns the enum key (i.e. the constant name).
public getKey ( ) : mixed
Результат mixed

getValue() публичный Метод

public getValue ( ) : mixed
Результат mixed

isValid() публичный статический Метод

Check if is valid enum value
public static isValid ( $value ) : boolean
$value
Результат boolean

isValidKey() публичный статический Метод

Check if is valid enum key
public static isValidKey ( $key ) : boolean
$key
Результат boolean

keys() публичный статический Метод

Returns the names (keys) of all constants in the Enum class
public static keys ( ) : array
Результат array

toArray() публичный статический Метод

Returns all possible values as an array
public static toArray ( ) : array
Результат array Constant name in key, constant value in value

values() публичный статический Метод

Returns instances of the Enum class of all Enum constants
public static values ( ) : static[]
Результат static[] Constant name in key, Enum instance in value

Описание свойств

$cache защищенное статическое свойство

Store existing constants in a static cache per object.
protected static array $cache
Результат array

$value защищенное свойство

Enum value
protected mixed $value
Результат mixed