public static function create($value, $empty = null)
    {
        // Option is a callable class!
        $value = ( ! $value instanceof self) && is_callable($value) ? $value() : $value;

        if (is_callable($empty)) {
            $option = $empty($value) ? self::$none : new Some($value);
        } else if ($value === $empty) {
            $option = self::$none;
        } else if ($value instanceof self) {
            $option = $value;
        } else {
            $option = new Some($value);
        }

        return $option;
    }
public static function create($value, $empty = null)
    {
        // Option is a callable class!
        $value = ( ! $value instanceof self) && is_callable($value) ? $value() : $value;

        if (is_callable($empty)) {
            $option = $empty($value) ? self::$none : new Some($value);
        } else if ($value === $empty) {
            $option = self::$none;
        } else if ($value instanceof self) {
            $option = $value;
        } else {
            $option = new Some($value);
        }

        return $option;
    }
public static function create ( $ value , $ empty = null ) { // Option is a callable class! $ value = ( ! $ value instanceof self ) && is_callable ( $ value ) ? $ value ( ) : $ value ; if ( is_callable ( $ empty ) ) { $ option = $ empty ( $ value ) ? self :: $ none : new Some ( $ value ) ; } else if ( $ value === $ empty ) { $ option = self :: $ none ; } else if ( $ value instanceof self ) { $ option = $ value ; } else { $ option = new Some ( $ value ) ; } return $ option ; }
Create new Option object.

By default it creates a None if $value is null,
Some($value) otherwise.

$value can be:
1. another Option
2. a callback
3. any other PHP value

$empty parameter is used to determine if $value
is empty or not and it can be:
1. a callback - which is called with $value
as parameter: if it returns a falsy value a None is created
2. any other PHP value - which is strictly compared to $value:
if they are equals a None is created.

@param mixed $value
@param mixed $empty Optional.
@return Option
Create new Option object .