-
v2, RC 1 Pre-Release
released this
2024-10-01 03:10:40 +00:00 | 1 commits to main since this releaseThis release candidate moves the project to PHP 8.4.
- In both
Option
andResult
, theis*
functions are now properties. - In
Option
,get()
is now thevalue
property. Other functions, likegetOrDefault()
, remain the same. - In
Result
,getOK()
andgetError()
are nowok
anderror
properties.
Downloads
- In both
-
v1, Beta 2 Pre-Release
released this
2024-07-29 20:50:13 +00:00 | 4 commits to main since this releaseBREAKING CHANGE
Option->is()
has been renamedOption->contains()
for consistency withResult
(and any future collection implementation).FEATURES
BothOption
andResult
now support:bind
: takes a callback that accepts the Some or OK value and returns anOption
orResult
, respectively. If theOption
is None or theResult
is Error, the callback will be skipped. This allows what is termed "railway-oriented programming" where every call is an opportunity to short-circuit the rest of the calls and return the Error result (or None).contains
: takes a value and an optionalstrict:
parameter; it returnstrue
if the Some or OK value matches the value provided, orfalse
otherwise.exists
: takes a callback that accepts the Some or OK value and returnsbool
; None or Error results always returnfalse
.toArray
: converts a SomeOption
and an OKResult
to a one-item array, and converts a NoneOption
and an ErrorResult
to an empty array.
Additionally,
Option
now has agetOrThrow
method that takes a callback that returns anException
. If theOption
is Some, the value is returned; if it is None, the callback is called and the resultingException
is thrown.Downloads
-
v1, Beta 1 Pre-Release
released this
2024-07-28 21:38:12 +00:00 | 6 commits to main since this releaseThis is the initial release of this library; see the README for what, how, and why. :)
Downloads