PHP 클래스 MyCLabs\Enum\Enum

Create an enum by implementing this class and adding class constants.
파일 보기 프로젝트 열기: myclabs/php-enum 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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