aeviiq / enum
Enum Component
Installs: 15 733
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^8.1
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpstan/phpstan-phpunit: ^1.3
- phpstan/phpstan-strict-rules: ^1.5
- phpunit/phpunit: ^10.0
- psalm/plugin-phpunit: ^0.18.4
- thecodingmachine/phpstan-strict-rules: ^1.0
- vimeo/psalm: ^5.4
README
Why
To provide a way to implement enum flags in PHP.
Installation
composer require aeviiq/enum
Declaration
final class Foo extends AbstractFlag { public const BAR = 1; public const BAZ = 2; // ... }
Usage
$foo = new Foo(Foo:BAR); $foo->contains(new Foo(Foo:BAR)); // True $foo->contains(new Foo(Foo:BAZ)); // False $foo->contains(new Bar(Foo::BAR)); // InvalidArgumentException thrown $foo = new Foo(6); // UnexpectedValueException thrown