esky/enum

PHP Enum implementation

1.1.1 2015-05-17 09:47 UTC

This package is not auto-updated.

Last update: 2024-11-19 08:41:09 UTC


README

Build Status

##Documentation

construct

$type = new Type(Type::BASIC);
$type = Type::createFromConstantName('BASIC');
$type = Type::BASIC();

new Type(5); // InvalidArgumentException

instance methods

$type->getValue(); // 1
$type->getName(); // BASIC
$type->isEqual($type); // true
$type->isEqual(Type::Basic); // true

static methods

Type::getValues(); // [1, 2]
Type::getNames(); // [1 => 'BASIC', 2 => 'COMPLEX']
Type::getNames([2]); // [2 => 'COMPLEX']

Type::isValidValue(1); // true
Type::isValidValue(3); // false

handle null value

$nullType = new Type(null);

$nullType->getName(); // null
$nullType->getValue(); // null