Add support for defining Groups and Subgroups as enums #932
+66
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When defining groups and subgroups, it's nice to have a clear idea of what groups are available to use. PHP Backed Enums are a perfect way of achieving this. Otherwise, developers could mis-type group names easily such as;
Solution
By allowing the usage of Backed Enums, it is very clean to be able to define your API Endpoint Groups as an enum;
Then in your codebase you can simply do;
Alternative
An alternative could be to just add
->value
to each enum which would not require any codebase changes however this is not visually pleasing and not as nice of a DX as being able to pass an enum directly.