The Enum Component
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
src
tests
.gitattributes
.gitignore
.scrutinizer.yml
.travis.yml
LICENSE
README.md
composer.json
phpunit.xml.dist

README.md

Enum

Build Status Code Coverage Scrutinizer Code Quality SensioLabsInsight

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