oskarstark/enum-helper
Helpers for PHP 8.1+ enums: compare enum cases (equals, notEquals, equalsOneOf) and convert enums to arrays (backed and non-backed). Includes an abstract EnumTestCase to simplify testing enum behavior.
isNice()) that encapsulate business logic.EnumTestCase abstract class, reducing flakiness in test suites.Adopt if:
UserRole, OrderStatus).EnumTestCase base class.Look elsewhere if:
For Executives:
"This package lets us write cleaner, more maintainable code for enums—common in our Laravel apps—without reinventing the wheel. It adds two simple traits for comparing enums (e.g., checking if a UserRole is ADMIN) and converting them to arrays (for APIs/forms), plus a test helper to speed up QA. It’s a 10-minute setup with long-term payoffs in readability and developer velocity. MIT license means no vendor lock-in."
For Engineers: *"Need to compare enums or serialize them to arrays? This package gives you:
Comparable trait: equals(), notEquals(), equalsOneOf() for clean logic (e.g., if ($status->isActive())).ToArray trait: One-liner for API responses or form inputs (works for both backed/non-backed enums).EnumTestCase: Abstract base class to DRY up enum tests.
It’s zero-config, PHP 8.1+, and MIT-licensed. Let’s use it for new enums and migrate existing ones where it saves time."*How can I help you explore Laravel packages today?