Skip to content

Commit

Permalink
Document try/catch in native enum conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Sep 1, 2023
1 parent 97cbf47 commit 393db27
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ Review and validate the code changes for missed edge cases:
- `Enum::coerce()`: If only values were passed, you can replace it with `tryFrom()`.
If keys or instances could also be passed, you might need additional logic to cover this.
- `Enum::$description` and `Enum::getDescription()`: Implement an alternative.
- try/catch-blocks that handle `BenSampo\Enum\Exceptions\InvalidEnumKeyException` or `BenSampo\Enum\Exceptions\InvalidEnumMemberException`.
Either catch the `ValueError` thrown by native enums, or switch to using `tryFrom()` and handle `null`.

Once all enums are converted, you can remove your dependency on this library.

Expand Down

0 comments on commit 393db27

Please sign in to comment.