esky / enum
PHP Enum implementation
Installs: 84 555
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: 3.7.23
This package is not auto-updated.
Last update: 2024-11-19 08:41:09 UTC
README
##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