smt/enumeration

This package is abandoned and no longer maintained. No replacement package was suggested.

Very basic (also lightweight) helper for enumeration classes

v1.0.0 2015-08-27 09:16 UTC

This package is not auto-updated.

Last update: 2017-09-10 16:02:00 UTC


README

Very basic (also lightweight) helper for enumeration classes based on traits.

Installation

composer require smt/enumeration

Usage

use Smt\Util\Enumeration\EnumerationTrait;

final class SomeEnumeration
{
    const SOME_VALUE = 'hello world';
    const SOME_ANOTHER_VALUE = '...';

    use EnumerationTrait;
}

var_dump(SomeEnumeration::all());
// array(2) {
//   'SOME_VALUE' =>
//   string(11) "hello world"
//   'SOME_ANOTHER_VALUE' =>
//   string(3) "..."
// }

new SomeEnumeration(); // PHP Fatal error:  Call to private SomeEnumeration::__construct() from invalid context