FOF30\Input\Input::_cleanVar PHP Méthode

_cleanVar() protected méthode

Custom filter implementation. Works better with arrays and allows the use of a filter mask.
protected _cleanVar ( mixed $var, integer $mask, string $type = null ) : mixed
$var mixed The variable (value) to clean
$mask integer The clean mask
$type string The variable type
Résultat mixed
    protected function _cleanVar($var, $mask = 0, $type = null)
    {
        if (is_array($var)) {
            $temp = array();
            foreach ($var as $k => $v) {
                $temp[$k] = self::_cleanVar($v, $mask);
            }
            return $temp;
        }
        // If the no trim flag is not set, trim the variable
        if (!($mask & 1) && is_string($var)) {
            $var = trim($var);
        }
        // Now we handle input filtering
        if ($mask & 2) {
            // If the allow raw flag is set, do not modify the variable
        } elseif ($mask & 4) {
            // If the allow HTML flag is set, apply a safe HTML filter to the variable
            $safeHtmlFilter = \JFilterInput::getInstance(null, null, 1, 1);
            $var = $safeHtmlFilter->clean($var, $type);
        } else {
            $var = $this->filter->clean($var, $type);
        }
        return $var;
    }