23 if (!is_string(
$error) && !(
$error instanceof \Exception)) {
24 throw new \InvalidArgumentException(
"Expected error to be a string or an Exception.");
41 if ($this->
error instanceof \Exception) {
75 public function map(callable $f)
83 public function then(callable $f)
100 throw new \UnexpectedValueException(
"The returned type of callable is not an instance of interface Result");
An exception for terminatinating execution or to throw for unit testing.
Signals that a result contains no value.
A result encapsulates a value or an error and simplifies the handling of those.
map(callable $f)
Create a new result where the contained value is modified with $f.Does nothing if !...
except(callable $f)
Feed the error into a callable and replace this with the result or do nothing if this is a value....
error()
Get the encapsulated error.Exception|string
then(callable $f)
Get a new result from the callable or do nothing if this is an error.If null is returned from $f,...
value()
Get the encapsulated value.mixed
valueOr($default)
Get the encapsulated value or the supplied default if result is an error.mixed
isError()
Get to know if the result is an error.bool
isOK()
Get to know if the result is ok.bool
A result encapsulates a value or an error and simplifies the handling of those.