src/Traits/CrudModels.php
private static function evaluateFilterWithSingleQuery($registro, $query, $attri) {
        //echo "<p>evaluando {$registro->name}</p><pre>" . print_r([$query, $attri], true) . "</pre>";
        $contiene = false;
        if (stripos($query, "*%") !== false) {
            $contiene = true;
            $query = str_replace("*%", "", $query);
        }

        if (($numArgs = \Sirgrimorum\CrudGenerator\CrudGenerator::isFunction($registro, $attri)) !== false) {
            //echo "<p>NumArgs $numArgs</p>";
            if (\Sirgrimorum\CrudGenerator\CrudGenerator::isJsonString($query)) {
                $queryArr = json_decode($query, true);
            } else {
                $queryArr = [$query];
            }
            $result = \Sirgrimorum\CrudGenerator\CrudGenerator::callFunction($registro, $attri, $queryArr, $numArgs);
            if ($result === false || $result === null) {
                return false;
            } else {
                $queryObj = array_pop($queryArr);
                if ($result != $queryObj) {
                    return false;
                }
            }
        } elseif (is_string($registro->{$attri})) {
            //echo "<p> stripos es " . stripos($registro->{$attri}, $query) . " jajaj</p>";
            if ($contiene) {
                if (stripos($registro->{$attri}, $query) === false) {
                    return false;
                }
            } else {
                if ($registro->{$attri} != $query) {
                    return false;
                }
            }
        } else {
            if ((string) $registro->{$attri} != $query) {
                return false;
            }
        }
        return true;
    }
private static function evaluateFilterWithSingleQuery($registro, $query, $attri) {
        //echo "<p>evaluando {$registro->name}</p><pre>" . print_r([$query, $attri], true) . "</pre>";
        $contiene = false;
        if (stripos($query, "*%") !== false) {
            $contiene = true;
            $query = str_replace("*%", "", $query);
        }

        if (($numArgs = \Sirgrimorum\CrudGenerator\CrudGenerator::isFunction($registro, $attri)) !== false) {
            //echo "<p>NumArgs $numArgs</p>";
            if (\Sirgrimorum\CrudGenerator\CrudGenerator::isJsonString($query)) {
                $queryArr = json_decode($query, true);
            } else {
                $queryArr = [$query];
            }
            $result = \Sirgrimorum\CrudGenerator\CrudGenerator::callFunction($registro, $attri, $queryArr, $numArgs);
            if ($result === false || $result === null) {
                return false;
            } else {
                $queryObj = array_pop($queryArr);
                if ($result != $queryObj) {
                    return false;
                }
            }
        } elseif (is_string($registro->{$attri})) {
            //echo "<p> stripos es " . stripos($registro->{$attri}, $query) . " jajaj</p>";
            if ($contiene) {
                if (stripos($registro->{$attri}, $query) === false) {
                    return false;
                }
            } else {
                if ($registro->{$attri} != $query) {
                    return false;
                }
            }
        } else {
            if ((string) $registro->{$attri} != $query) {
                return false;
            }
        }
        return true;
    }
private static function evaluateFilterWithSingleQuery ( $ registro , $ query , $ attri ) { //echo "<p>evaluando {$registro->name}</p><pre>" . print_r([$query, $attri], true) . "</pre>"; $ contiene = false ; if ( stripos ( $ query , "*%" ) !== false ) { $ contiene = true ; $ query = str_replace ( "*%" , "" , $ query ) ; } if ( ( $ numArgs = \ Sirgrimorum \ CrudGenerator \ CrudGenerator :: isFunction ( $ registro , $ attri ) ) !== false ) { //echo "<p>NumArgs $numArgs</p>"; if ( \ Sirgrimorum \ CrudGenerator \ CrudGenerator :: isJsonString ( $ query ) ) { $ queryArr = json_decode ( $ query , true ) ; } else { $ queryArr = [ $ query ] ; } $ result = \ Sirgrimorum \ CrudGenerator \ CrudGenerator :: callFunction ( $ registro , $ attri , $ queryArr , $ numArgs ) ; if ( $ result === false || $ result === null ) { return false ; } else { $ queryObj = array_pop ( $ queryArr ) ; if ( $ result != $ queryObj ) { return false ; } } } elseif ( is_string ( $ registro -> { $ attri } ) ) { //echo "<p> stripos es " . stripos($registro->{$attri}, $query) . " jajaj</p>"; if ( $ contiene ) { if ( stripos ( $ registro -> { $ attri } , $ query ) === false ) { return false ; } } else { if ( $ registro -> { $ attri } != $ query ) { return false ; } } } else { if ( ( string ) $ registro -> { $ attri } != $ query ) { return false ; } } return true ; }
Filter an object of a model with a single query. It will use AND operation.

If $attri is a method or function fo the object it will try to evaluate it with
$query as parametter. Use a Json string to pass more than one parametter.
If the returned value is not a boolean or null, will use the $query or the las value of
the $query array to comare.

If $attri is only an attribute, it will compare against $query as it is.

if $query contains "*%" it will erase them and evaluate if $query is contained in the attribute value.
Not aplicable for function or methods returns

@param object $registro The model object
@param string $query The query to evaluate
@param string $attri The attribute to compare
@return boolean
Filter an object of a model with a single query . It will use AND operation .