<U>
Execute a callable and transform the result into an Option
.
It will be a Some
option containing the result if it is different from $noneValue
(default null
).
Successful execution:
self::assertEq(Option\of(fn() => "fruits"), Option\some("fruits"));
Convertion of null
to Option\None
:
self::assertEq(Option\of(fn() => null), Option\none());
Parameters | |||
---|---|---|---|
callable(): U
|
$callback |
# | |
mixed
|
$noneValue = null |
# | |
bool
|
$strict = true |
# |
Returns | |
---|---|
Option<U>
|