Comments (2)
Hey,
yes you can use the enums in a switch statement like follows:
switch(Gender::MALE()) {
case Gender::FEMALE():
return 'female';
case Gender::MALE():
return 'male';
}
That's just a super stupid example but tested in a project and it perfectly works. 🙂
from enum.
Thanks for fast and clear answer!
from enum.
Related Issues (20)
- Enum serialized as empty array when using spatie/laravel-event-sourcing and spatie/data-transfer-object HOT 3
- Doc link is broken HOT 2
- Strong typed enums problems HOT 2
- Unit test overridden values HOT 3
- Enums with Laravel Octane HOT 2
- initialize Enum with values coming from DB? HOT 2
- PHPUnit assertions trait changed to class HOT 6
- Too few arguments to function Spatie\Enum\Enum::__construct(), 0 passed HOT 3
- OPcache strip comments problem HOT 2
- Missing documentation for ->isXy() HOT 1
- Deprecate values HOT 1
- Localised labels aren't update after locale is changed HOT 2
- can php7.2 (or even 7.3) be supported? HOT 2
- Extend already extended HOT 2
- Creating enum using method call from within enum throws UnknownEnumMethod HOT 6
- Consider using generics for better IDE support HOT 8
- Future of this package after PHP 8.1 HOT 7
- Support standard strict comparison HOT 5
- PHP8.1 Compatibility: check properties HOT 1
- Fix "Creating an enum from a value" example in documentation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enum.