Skip to content

About

Smart, lightweight helpers for native PHP enums: one trait adds names(), values(), labels(), options(), fromName()/tryFromName(), is()/in() comparisons and is<Case>() checks, keeping PHP's own cases(), from() and tryFrom(). No runtime dependencies.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

PHP Version : 8.6 License Build
Source Packagist Version Packagist Downloads

Smart, lightweight helpers for native PHP enums.


Installation

composer require pharaonic/php-smart-enum

Usage

use Pharaonic\SmartEnum\SmartEnum;

enum Status: string
{
    use SmartEnum;

    case Pending = 'pending';
    case Active = 'active';
}

Status::options();                 // ['pending' => 'Pending', 'active' => 'Active']
Status::fromName('Active');        // Status::Active
Status::Active->is('active');      // true
Status::Active->isActive();        // true

Documentation

Full documentation: PHP Smart Enum Documentation.

Support & Security

See SUPPORT.md and SECURITY.md. Contributions are welcome; see CONTRIBUTING.md.

License

MIT. See LICENSE.

About

Smart, lightweight helpers for native PHP enums: one trait adds names(), values(), labels(), options(), fromName()/tryFromName(), is()/in() comparisons and is<Case>() checks, keeping PHP's own cases(), from() and tryFrom(). No runtime dependencies.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages