Option::fromValue( mixed $value, mixed $noneValue = null )
Creates an option given a return value.
Description
This is intended for consuming existing APIs and allows you to easily convert them to an option. By default, we treat null
as the None case, and everything else as Some.
Parameters
- $value
-
(Required) The actual return value.
- $noneValue
-
(Optional) The value which should be considered "None"; null by default.
Default value: null
Return
(PhpOptionOption)
Source
File: vendor/phpoption/phpoption/src/PhpOption/Option.php
public static function fromValue($value, $noneValue = null)
{
if ($value === $noneValue) {
return None::create();
}
return new Some($value);
}