public static function toConditionCallable($mixed=null)
    {
        // callable
        if(self::isClosure($mixed) || self::isInstanceCallable($mixed))
        {
            return $mixed;
        }
        // is bool
        elseif(is_bool($mixed) || is_string($mixed) || is_numeric($mixed))
        {
            return function($v) use($mixed) { return $v===$mixed; };
        }
        // conditions from array
        elseif(is_array($mixed) && count($mixed)>0)
        {
            return function($v) use($mixed)
            {
                foreach($mixed as $field => $expression)
                {
                    if(self::isClosure($expression) || self::isInstanceCallable($expression))
                    {
                        if(call_user_func($expression, $v[$field])!==true)
                        {
                            return false;
                        }
                    }
                    else
                    {
                        if((is_array($v) || $v instanceof \ArrayAccess) &&
                           $v[$field]!==$expression)
                        {
                            return false;
                        }
                    }
                }
                return true;
            };
        }

        throw new InvalidException("Could not convert expression of type ".gettype($mixed)." into a lambda callable");
    }
public static function toConditionCallable($mixed=null)
    {
        // callable
        if(self::isClosure($mixed) || self::isInstanceCallable($mixed))
        {
            return $mixed;
        }
        // is bool
        elseif(is_bool($mixed) || is_string($mixed) || is_numeric($mixed))
        {
            return function($v) use($mixed) { return $v===$mixed; };
        }
        // conditions from array
        elseif(is_array($mixed) && count($mixed)>0)
        {
            return function($v) use($mixed)
            {
                foreach($mixed as $field => $expression)
                {
                    if(self::isClosure($expression) || self::isInstanceCallable($expression))
                    {
                        if(call_user_func($expression, $v[$field])!==true)
                        {
                            return false;
                        }
                    }
                    else
                    {
                        if((is_array($v) || $v instanceof \ArrayAccess) &&
                           $v[$field]!==$expression)
                        {
                            return false;
                        }
                    }
                }
                return true;
            };
        }

        throw new InvalidException("Could not convert expression of type ".gettype($mixed)." into a lambda callable");
    }
public static function toConditionCallable ( $ mixed = null ) { // callable if ( self :: isClosure ( $ mixed ) || self :: isInstanceCallable ( $ mixed ) ) { return $ mixed ; } // is bool elseif ( is_bool ( $ mixed ) || is_string ( $ mixed ) || is_numeric ( $ mixed ) ) { return function ( $ v ) use ( $ mixed ) { return $ v === $ mixed ; } ; } // conditions from array elseif ( is_array ( $ mixed ) && count ( $ mixed ) > 0 ) { return function ( $ v ) use ( $ mixed ) { foreach ( $ mixed as $ field => $ expression ) { if ( self :: isClosure ( $ expression ) || self :: isInstanceCallable ( $ expression ) ) { if ( call_user_func ( $ expression , $ v [ $ field ] ) !== true ) { return false ; } } else { if ( ( is_array ( $ v ) || $ v instanceof \ ArrayAccess ) && $ v [ $ field ] !== $ expression ) { return false ; } } } return true ; } ; } throw new InvalidException ( "Could not convert expression of type " . gettype ( $ mixed ) . " into a lambda callable" ) ; }
Convert strings, numbers, booleans and arrays into a callable
@param type $mixed
@return type
@throws InvalidException
Convert strings numbers booleans and arrays into a callable