mibadger / enum
The Enum Component
Installs: 1 411
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.0 || ^8.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2022-11-19 17:10:32 UTC
README
The Enum Component.
Example
<?php use miBadger\Enum\Enum; /** * The example class. */ class Example extends Enum { const A = 'a'; const B = 'b'; }
<?php /** * Returns the enum object with the specified name. */ $enum = new Example(Example::A); /** * Returns the enum object with the specified name. */ $enum = Example::valueOf('A'); /** * Returns the ordinal. */ $enum->getOrdinal(); // 1 /** * Returns the name. */ $enum->getName(); // A /** * Returns the value. */ $enum->getValue(); // a