Optional (inspired by the functional thing), helps to:
- Better handling of exception (JustSuccess/Failure).
- Better typed alternative to the use of null (None/Some).
- Simplify the control flow on errors.
- Build failsafe code
- Improve testability.
Is a pragmatic version on the Optional/Either/Maybe from functional programing, it provides functionality present in such languages along some extra to solve some common use cases in php.
Some literature about, google for more:
https://www.thoughtworks.com/en-es/insights/blog/either-data-type-alternative-throwing-exceptions
https://itnext.io/either-monad-a-functional-approach-to-error-handling-in-js-ffdc2917ab2