j45l/maybe-php

Maybe for PHP

Installs: 5 998

Dependents: 0

Suggesters: 0

Security: 0

Stars: 6

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/j45l/maybe-php


README

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.

Optional

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

https://functionalprogramming.medium.com/either-is-a-common-type-in-functional-languages-94b86eea325c

Optional Documentation

Optional class

Support functions