esky/enum

PHP Enum implementation

Maintainers

Details

github.com/eskypl/enum

Source

Issues

Installs: 92 224

Dependents: 2

Suggesters: 0

Security: 0

Stars: 2

Watchers: 3

Forks: 1

Open Issues: 0

pkg:composer/esky/enum

1.1.1 2015-05-17 09:47 UTC

This package is not auto-updated.

Last update: 2025-10-07 12:30:29 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