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

Php Enum Laravel Package

paillechat/php-enum

PHP 7+ enum library: define enums by extending Enum and declaring constants, then instantiate via static named calls (IssueType::ONE()). Instances are strict-equal singletons, work with in_array/type hints, and can convert to/from names.

View on GitHub
Deep Wiki
Context7
1.2.1

Fix invalid deprecations for __toString() calls

2.1
  • Implemented createByName static constructor, useful for deserialization purposes.

Example:

$apiValue = 'bar';
$enum = MyEnum::createByName(strtoupper($apiValue));
1.2
  • Implemented hard deprecations for calls to be removed or changed in 2.0

    • equals - use == comparison, upgrade to === on 2.0
    • __construct. Use MyEnum::createByName('BAR') or MyEnum::BAR()
    • getValue. Cast to string instead. Will return enum value until 2.0, enum name after.
    • toInt will be removed. Switch to name based enums
  • Implemented createByName function to instantiate enum by constant name - preferred option for deserializing purpose. example:

$apiValue = 'bar';
$value = MyEnum::createByName(strtoupper($apiValue))
  • For known constant names use MyEnum::BAR() syntax.
2.0

New featires

Use one instance of type value everywhere. Possibility to get name of Enum member.

Removed fatures

Excplicit equality check method (replace with general strict comparison ===) Remove any value management features (enums are about named instances)

1.1
1.0.3

Now we can get available values without instantiate class.

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.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console