Weave Code
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky