Ok
in package
implements
Result
Read onlyYes
FinalYes
Tags
Table of Contents
Interfaces
- Result
- Result monad as a `Either monad`.
Methods
- and() : Result<U, E>
- andThen() : E>)
- NOTE: PHPdoc's completion by type specification in Closure doesn't work, so I'm redefining it.
- err() : Option<string|int, E>
- expect() : T
- getIterator() : Traversable
- inspect() : $this
- inspectErr() : $this
- isErr() : false
- isErrAnd() : false
- isOk() : true
- isOkAnd() : bool
- map() : U>
- mapErr() : $this
- mapOr() : U
- mapOrElse() : U
- match() : U|V
- Applies one of two functions depending on whether the result is Ok or Err.
- ok() : Some<string|int, T>
- or() : $this
- orElse() : $this
- orThrow() : $this
- Returns the contained Ok value or throws the provided exception.
- unwrap() : T
- unwrapErr() : E
- unwrapOr() : T|U
- unwrapOrElse() : T|U
- unwrapOrThrow() : T
- Returns the contained Ok value or throws the provided exception.
Methods
and()
public
and(Result $right) : Result<U, E>
Parameters
- $right : Result
Attributes
- #[Override]
Return values
Result<U, E>andThen()
NOTE: PHPdoc's completion by type specification in Closure doesn't work, so I'm redefining it.
public
andThen(Closure $right) : E>)
Parameters
- $right : Closure
Tags
Attributes
- #[Override]
Return values
E>)err()
public
err() : Option<string|int, E>
Attributes
- #[Override]
Return values
Option<string|int, E>expect()
public
expect(string $message) : T
Parameters
- $message : string
Attributes
- #[Override]
Return values
TgetIterator()
public
getIterator() : Traversable
Attributes
- #[Override]
Return values
Traversableinspect()
public
inspect(Closure $callback) : $this
Parameters
- $callback : Closure
Attributes
- #[Override]
Return values
$thisinspectErr()
public
inspectErr(Closure $callback) : $this
Parameters
- $callback : Closure
Attributes
- #[Override]
Return values
$thisisErr()
public
isErr() : false
Attributes
- #[Override]
Return values
falseisErrAnd()
public
isErrAnd(Closure $predicate) : false
Parameters
- $predicate : Closure
Attributes
- #[Override]
Return values
falseisOk()
public
isOk() : true
Attributes
- #[Override]
Return values
trueisOkAnd()
public
isOkAnd(Closure $predicate) : bool
Parameters
- $predicate : Closure
Attributes
- #[Override]
Return values
boolmap()
public
map(callable(T): U $callback) : U>
Parameters
- $callback : callable(T): U
Tags
Attributes
- #[Override]
Return values
U>mapErr()
public
mapErr(Closure $callback) : $this
Parameters
- $callback : Closure
Attributes
- #[Override]
Return values
$thismapOr()
public
mapOr(Closure $callback, mixed $default) : U
Parameters
- $callback : Closure
- $default : mixed
Attributes
- #[Override]
Return values
UmapOrElse()
public
mapOrElse(Closure $callback, Closure $default) : U
Parameters
- $callback : Closure
- $default : Closure
Attributes
- #[Override]
Return values
Umatch()
Applies one of two functions depending on whether the result is Ok or Err.
public
match(Closure $okFn, Closure $errFn) : U|V
Comparable to neverthrow's match method.
Parameters
- $okFn : Closure
-
Function to apply if the Result is Ok
- $errFn : Closure
-
Function to apply if the Result is Err
Attributes
- #[Override]
Return values
U|V —The result of applying the appropriate function
ok()
public
ok() : Some<string|int, T>
Attributes
- #[Override]
Return values
Some<string|int, T>or()
public
or(Result $right) : $this
Parameters
- $right : Result
Attributes
- #[Override]
Return values
$thisorElse()
public
orElse(Closure $right) : $this
Parameters
- $right : Closure
Attributes
- #[Override]
Return values
$thisorThrow()
Returns the contained Ok value or throws the provided exception.
public
orThrow(Throwable $exception) : $this
Parameters
- $exception : Throwable
-
The exception to throw if the result is Err
Tags
Attributes
- #[Override]
Return values
$thisunwrap()
public
unwrap() : T
Attributes
- #[NoDiscard]
- #[Override]
Return values
TunwrapErr()
public
unwrapErr() : E
Tags
Attributes
- #[Override]
Return values
EunwrapOr()
public
unwrapOr(mixed $default) : T|U
Parameters
- $default : mixed
Attributes
- #[NoDiscard]
- #[Override]
Return values
T|UunwrapOrElse()
public
unwrapOrElse(Closure $default) : T|U
Parameters
- $default : Closure
Attributes
- #[NoDiscard]
- #[Override]
Return values
T|UunwrapOrThrow()
Returns the contained Ok value or throws the provided exception.
public
unwrapOrThrow(F $exception) : T
Parameters
- $exception : F
Tags
Attributes
- #[NoDiscard]
- #[Override]