| Visibility | Function |
|---|---|
| public static | ok(T $value): Create an Ok result. |
| public static | error(E $error): Create an error result. |
| public | and(Returns res if the result is Ok, otherwise returns the Err value of self. |
| public | andThen(\callable $op): Calls op if the result is Ok, otherwise returns the Err value of self. |
| public | contains(T $value): voidReturns true if the result is an Ok value containing the given value (compared with ==). |
| public | containsError(E $error): voidReturns true if the result is an error containing the given value (comapred with ==). |
| public | containsSame(T $value): voidReturns true if the result is an Ok value containing the given value (compared with ===). |
| public | containsSameError(E $error): voidReturns true if the result is an error containing the given value (comapred with ===). |
| public | errorValue(): Converts from Result<T,E> to Option, and discarding the Ok value, if any. |
| public | expect(\string $errorMessage): TReturns the contained Ok value or throws a ResultError with a custom message if result is an error |
| public | expectError(\string $errorMessage): EReturns the contained error value or throws a ResultError with a custom message if result is Ok |
| public | flatten(): Converts from Result<Result<T,E>,E> to Result<T,E> |
| public | getIterator(): \Generator |
| public | isError(): boolReturns true if the result is an error. |
| public | isOk(): boolReturns true if the result is Ok. |
| public | map(\callable $f): Maps a Result<T,E> to Result<U,E> by applying a function to a contained Ok value, leaving an Err value untouched. |
| public | mapError(\callable $f): Maps a Result<T,E> to Result<T,F> by applying a function to a contained Err value, leaving an Ok value untouched. |
| public | mapOr(\callable $f, U $default): UApplies a function to the contained value (if Ok), or returns the provided default (if Err). |
| public | mapOrElse(\callable $f, \callable $fallback): UMaps a Result<T,E> to U by applying a function to a contained Ok value, or a fallback function to a contained Err value. |
| public | okValue(): Converts from Result<T,E> to Option, and discarding the error, if any. |
| public | or(Returns res if the result is an error, otherwise returns the Ok value of self. |
| public | orElse(\callable $op): Calls op if the result is an error, otherwise returns the Ok value of self. |
| public | transpose(): Transposes a Result of an Option into an Option of a Result. |
| public | unwrap(): TReturns the contained Ok value or throws a ResultError if result is an error |
| public | unwrapError(): EReturns the contained error value or throws a ResultError if result is an error |
| public | unwrapOr(T $default): TReturns the contained Ok value or a provided default. |
| public | unwrapOrElse(\callable $f): TReturns the contained Ok value or computes it from a closure. |
This class implements \Traversable
| Visibility | Function |
|---|---|
| public static | some(T $value): Create an option with a value |
| public static | none(): Create an empty Option |
| public | and(Returns None if the option is None, otherwise returns option b. |
| public | andThen(\callable $f): Returns None if the option is None, otherwise calls f with the wrapped value and returns the result |
| public | contains(T $value): voidReturns true if the option contains the given value (compared with ==) |
| public | containsSame(T $value): voidReturns true if the option contains the given value (compared with ===) |
| public | expect(\string $errorMessage): TReturns the contained value or throws a NoneError with a custom message if empty |
| public | expectNone(\string $errorMessage): voidThrows a NoneError with a custom message if not empty |
| public | filter(\callable $p): Returns None if the option is None, otherwise calls predicate with the wrapped value and returns: * Some(t) if predicate returns true (where t is the wrapped value), and * None if predicate returns false. |
| public | flatten(): Converts from Option<Option> to Option |
| public | getIterator(): \Generator |
| public | isNone(): boolReturns true if the option is none |
| public | isSome(): boolReturns true if the option contains a value |
| public | map(\callable $f): Maps to another option by applying a function to the contained value |
| public | mapOr(\callable $f, U $value): UApplies a function to the contained value (if any), or returns the provided default (if not). |
| public | mapOrElse(\callable $f, \callable $default): UApplies a function to the contained value (if any), or compute a default (if not). |
| public | okOr(E $error): Transforms the Option into a Result<T,E>, mapping Some(v) to Ok(v) and None to Err(err). |
| public | okOrElse(\callable $error): Transforms the Option into a Result<T,E>, mapping Some(v) to Ok(v) and None to Err(error()). |
| public | or(Returns the option if it contains a value, otherwise returns option b. |
| public | orElse(\callable $f): Returns the option if it contains a value, otherwise calls f and returns the result. |
| public | transpose(): Transposes an Option of a Result into a Result of an Option. |
| public | unwrap(): TReturns the contained value or throws a NoneError if empty |
| public | unwrapNone(): voidThrows a NoneError if empty |
| public | unwrapOr(T $value): TReturns the contained value or the given value |
| public | unwrapOrElse(\callable $f): TReturns the contained value or compute it from the given closure |
| public | xor(Returns Some if exactly one of this and option b is Some, otherwise returns None. |
| public | zip(Zips self with another Option. If self is Some(s) and other is Some(o), this method returns Some([s, o])). Otherwise, None is returned |
| public | zipWith(Zips self with another Option with function f If self is Some(s) and other is Some(o), this method returns Some(f(s, o))). Otherwise, None is returned |
This class implements \Traversable