Option::fromArraysValue( mixed $array, string $key )
Creates an option from an array’s value.
Description
If the key does not exist in the array, the array is not actually an array, or the array’s value at the given key is null, None is returned.
Otherwise, Some is returned wrapping the value at the given key.
Parameters
- $array
-
(mixed) (Required) a potential array value
- $key
-
(string) (Required) the key to check
Return
(PhpOptionOption)
Source
File: vendor/phpoption/phpoption/src/PhpOption/Option.php
public static function fromArraysValue($array, $key)
{
if ( ! isset($array[$key])) {
return None::create();
}
return new Some($array[$key]);
}