Result
Table of Contents
Classes
Functions
- ok() : Ok<string|int, U>
- Return a `Result\Ok` Result containing `$value`.
- err() : Err<string|int, F>
- Return a `Result\Err` result.
- fromThrowable() : Result<T, E>
- Creates a Result from a Closure that may throw an exception.
- flatten() : Result<T, E>
- Converts from `Result<Result<T, E>, E>` to `Result<T, E>`.
- transpose() : Option<string|int, Result<U, F>>
- Transposes a `Result` of an `Option` into an `Option` of a `Result`.
- combine() : Result<bool, array<int, E>>
Functions
ok()
Return a `Result\Ok` Result containing `$value`.
ok([U $value = true ]) : Ok<string|int, U>
Parameters
- $value : U = true
Tags
Return values
Ok<string|int, U>err()
Return a `Result\Err` result.
err(F $value) : Err<string|int, F>
Parameters
- $value : F
Tags
Return values
Err<string|int, F>fromThrowable()
Creates a Result from a Closure that may throw an exception.
fromThrowable(callable(): T $closure, callable(Throwable): E $errorHandler) : Result<T, E>
Parameters
- $closure : callable(): T
- $errorHandler : callable(Throwable): E
Tags
Return values
Result<T, E>flatten()
Converts from `Result<Result<T, E>, E>` to `Result<T, E>`.
flatten(Result<Result<T, E1>, E2> $result) : Result<T, E>
Parameters
Tags
Return values
Result<T, E>transpose()
Transposes a `Result` of an `Option` into an `Option` of a `Result`.
transpose(Result<Option<string|int, U>, F> $result) : Option<string|int, Result<U, F>>
Ok(None) will be mapped to None.
Ok(Some(_)) and Err(_) will be mapped to Some(Ok(_)) and Some(Err(_)).
Parameters
Tags
Return values
Option<string|int, Result<U, F>>combine()
combine(Result<T, E> ...$results) : Result<bool, array<int, E>>
Parameters
- $results : Result<T, E>