Download the PHP package githubjeka/enum without Composer
On this page you can find all versions of the php package githubjeka/enum. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download githubjeka/enum
More information about githubjeka/enum
Files in githubjeka/enum
Package enum
Short Description Simple and base functional to start using Enum in your projects.
License MIT
Informations about the package enum
Usage ENUM
Simple and base functional to start using Enum in your projects. Just initialize enum value by creating Enum class.
After that you can use API enums as:
SizeEnum::getList()
Return ready list for use in HTML list elements like checkboxes, select or others
SizeEnum::getKeys()
Return values of ENUM for use it in validation rules like Assertion::inArray('xs', SizeEnum::getKeys());
;
SizeEnum::XXL
Return string key. Use to compare with the saved values (bool)('xxl' === SizeEnum::XXL)?>
;
SizeEnum::getLabel(SizeEnum::LARGE)
Return human description of value. InvalidArgumentException
will be returned if value is wrong.
SizeEnum::isValid('xl')
Use to avoid InvalidArgumentException
exception.
new SizeEnum('xxl')
Return Object enum.
Extra
Strongly recommend that you do not use numbers as enumeration values:
because it is easy to mix up the strings and the underlying number values if you quote the ENUM values incorrectly.
By default expected that all Enum(constants) are Strings.
If you want to use integers you can change $stringMode
property to FALSE
in your Enum class. After that should
use only integers value for constants: