1.0.7 2020-07-24 18:41 UTC

This package is auto-updated.

Last update: 2024-09-25 04:33:01 UTC


README

Latest build status: CircleCI
Github: https://github.com/softbucket/enum
Packagist: https://packagist.org/packages/softbucket/enum

Feel free to support me :D

Donate

What you're getting in this package

1. Simple

The softbucket implementation does not require constants to be defined.

<?php
use Softbucket\Enum\Enum;

/**
 * @method static self AM()
 * @method static self PM()
 */
class Meridiem extends Enum
{
}

2. Comparator Support === and ==

Use PHP's natural comparator. This works by comparing objects references.

Meridiem::one() === Meridiem::one() //true
Meridiem::one() == Meridiem::one() //also true

3. Easy Parsing

Parsing a string into an enum is very easy.

$AMString = 'AM';
Meridiem::{$AMString}(); 

4. Helper utility methods

The Enum objects are clean of utility methods. Use EnumHelper to grab am array of Enums.

EnumHelper::allEnums(Meridiem::class);
EnumHelper::serialize($enum);
EnumHelper::unserialize($enumString);

Goodbye

Enum::getName()

Enum::fromName()

Enum::values()

Enum::getConstants()

5. Fast Enums

Using simple array caching.

Thank you for choosing the cleanest php Enum package. I hope you enjoyed using this package and please spread the word for me!