Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Enumhancer Laravel Package

henzeb/enumhancer

View on GitHub
Deep Wiki
Context7

Value

Basic enums don't have a value. But if you want to know their numeric key or their value, you are referred to name and cases() respectively to find out. Value eases that problem for you.

Usage

use Henzeb\Enumhancer\Concerns\Value;

enum yourEnum {
    use Value;

    case MY_ENUM;
    case Other;

}

Examples

YourEnum::MY_ENUM->value(); // will return `my_enum`;
YourEnum::Other->value(); // will return `other`;

YourEnum::MY_ENUM->key(); // will return `0`;
YourEnum::Other->key(); // will return `1`;

Note: When used with a string or int backed enum, value will return it's actual value.

Note: When used with an int backed enum, key will return the value.

Strict values

By default, the value of a UnitEnum will be the lower cased value of the enum case. With strict, you can modify this behavior so it returns uppercase.

Strict example

use Henzeb\Enumhancer\Concerns\Value;

enum yourEnum {
    use Value;

    const STRICT = true;

    case MY_ENUM;
    case Other;

}

yourEnum::Other->value(); // returns Other
yourEnum::MY_ENUM->value(); // returns MY_ENUM
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator