Skip to content

Releases: Ne-Lexa/enum

1.1 (added initialization enum from value)

07 Nov 10:34
Compare
Choose a tag to compare

Added new method Enum::fromValue(mixed $value): static.

Example:

<?php

use Nelexa\Enum;

/**
 * @method static self PENDING()
 * @method static self ACTIVE()
 * @method static self INACTIVE()
 * @method static self DELETED()
 */
class UserStatus extends Enum
{
    public const
        PENDING = 1,
        ACTIVE = 1 << 1,
        INACTIVE = 1 << 2,
        DELETED = 1 << 3;
}

assert(UserStatus::fromValue(1 << 1) === UserStatus::valueOf('ACTIVE'));

1.0.1

10 Jun 12:41
Compare
Choose a tag to compare

Fix generate PHPDoc for enum class.

Installation:

composer require nelexa/enum

Update:

composer update nelexa/enum