There is no license information available for the latest version (v2.0.0) of this package.

v2.0.0 2020-10-13 10:03 UTC

This package is auto-updated.

Last update: 2022-06-13 14:00:37 UTC


Type safe enums

Getting started

Create enum class

 * @method static self ENGLAND() 
 * @method static self USA() 
class CountryEnum extends Enum
    protected static function getEnums(): array
        return ['england', 'usa'];



static method must be always uppercase

assert(CountryEnum::USA() === CountryEnum::USA());

function country(CountryEnum $country): string {
    return $country->value();

assert(country(CountryEnum::USA()) === 'usa');

convert enum value to object:

assert(CountryEnum::get('usa') === CountryEnum::USA());