public static function createLambda($closure, string $closureArgs, $default = null)
    {
        if ($closure === null) {
            if ($default === null)
                throw new \InvalidArgumentException(self::ERROR_CLOSURE_NULL);
            return $default;
        }
        if ($closure instanceof \Closure)
            return $closure;
        if (is_string($closure) && ($function = self::createLambdaFromString($closure, $closureArgs)))
            return $function;
        if (is_callable($closure))
            return $closure;
        throw new \InvalidArgumentException(self::ERROR_CLOSURE_NOT_CALLABLE);
    }
public static function createLambda($closure, string $closureArgs, $default = null)
    {
        if ($closure === null) {
            if ($default === null)
                throw new \InvalidArgumentException(self::ERROR_CLOSURE_NULL);
            return $default;
        }
        if ($closure instanceof \Closure)
            return $closure;
        if (is_string($closure) && ($function = self::createLambdaFromString($closure, $closureArgs)))
            return $function;
        if (is_callable($closure))
            return $closure;
        throw new \InvalidArgumentException(self::ERROR_CLOSURE_NOT_CALLABLE);
    }
public static function createLambda ( $ closure , string $ closureArgs , $ default = null ) { if ( $ closure === null ) { if ( $ default === null ) throw new \ InvalidArgumentException ( self :: ERROR_CLOSURE_NULL ) ; return $ default ; } if ( $ closure instanceof \ Closure ) return $ closure ; if ( is_string ( $ closure ) && ( $ function = self :: createLambdaFromString ( $ closure , $ closureArgs ) ) ) return $ function ; if ( is_callable ( $ closure ) ) return $ closure ; throw new \ InvalidArgumentException ( self :: ERROR_CLOSURE_NOT_CALLABLE ) ; }
Convert string lambda to callable function. If callable is passed, return as is.
@param callable|null $closure
@param string $closureArgs
@param \Closure|callable|null $default
@throws \InvalidArgumentException Both closure and default are null.
@throws \InvalidArgumentException Incorrect lambda syntax.
@return callable|null
Convert string lambda to callable function . If callable is passed return as is .