Filter

@param string $var
@return mixed
328024
protected function filter($var)
    {
        switch (true) {
            case strpos(trim($var), "#") === 0:
                return null;
            case strpos($var, "=") !== false:
                list($key, $val) = array_map("trim", explode("=", $var ,2));
                return array($key, $val);
            default:
                return null;
        }
    }
1355551
public function filter($value)
    {
        $filtered = parent::filter($value);
        return null === $filtered ? false : $filtered;
    }
928076
public function filter($value)
    {
        if (empty($value) && isset($this->filterData[$this->fieldToSlugFrom])) {
            $value = $this->filterData[$this->fieldToSlugFrom];
        }

        if (is_null($value)) {
            return $this->setEmpty();
        }

        $value = transliterator_transliterate($this->transliterator, $value);
        $value = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", $value);
        $value = preg_replace('/[^\w\d]+/', '-', $value);
        $value = trim($value, '-');
        return strtolower($value);
    }
283616
public function filter($value)
    {
        $type    = $this->getType();
        $casting = $this->getCasting();

        // LOCALIZED
        if ($type >= self::TYPE_LOCALIZED) {
            $type -= self::TYPE_LOCALIZED;
            if (is_string($value)) {
                if (isset($this->options['translations'][$value])) {
                    return (bool) $this->options['translations'][$value];
                }
            }
        }

        // FALSE_STRING ('false')
        if ($type >= self::TYPE_FALSE_STRING) {
            $type -= self::TYPE_FALSE_STRING;
            if (is_string($value) && (strtolower($value) == 'false')) {
                return false;
            }

            if (!$casting && is_string($value) && (strtolower($value) == 'true')) {
                return true;
            }
        }

        // NULL (null)
        if ($type >= self::TYPE_NULL) {
            $type -= self::TYPE_NULL;
            if ($value === null) {
                return false;
            }
        }

        // EMPTY_ARRAY (array())
        if ($type >= self::TYPE_EMPTY_ARRAY) {
            $type -= self::TYPE_EMPTY_ARRAY;
            if (is_array($value) && ($value == [])) {
                return false;
            }
        }

        // ZERO_STRING ('0')
        if ($type >= self::TYPE_ZERO_STRING) {
            $type -= self::TYPE_ZERO_STRING;
            if (is_string($value) && ($value == '0')) {
                return false;
            }

            if (!$casting && (is_string($value)) && ($value == '1')) {
                return true;
            }
        }

        // STRING ('')
        if ($type >= self::TYPE_STRING) {
            $type -= self::TYPE_STRING;
            if (is_string($value) && ($value == '')) {
                return false;
            }
        }

        // FLOAT (0.0)
        if ($type >= self::TYPE_FLOAT) {
            $type -= self::TYPE_FLOAT;
            if (is_float($value) && ($value == 0.0)) {
                return false;
            }

            if (!$casting && is_float($value) && ($value == 1.0)) {
                return true;
            }
        }

        // INTEGER (0)
        if ($type >= self::TYPE_INTEGER) {
            $type -= self::TYPE_INTEGER;
            if (is_int($value) && ($value == 0)) {
                return false;
            }

            if (!$casting && is_int($value) && ($value == 1)) {
                return true;
            }
        }

        // BOOLEAN (false)
        if ($type >= self::TYPE_BOOLEAN) {
            $type -= self::TYPE_BOOLEAN;
            if (is_bool($value)) {
                return $value;
            }
        }

        if ($casting) {
            return true;
        }

        return $value;
    }
1095828
public function filter($value)
    {
        $chain = clone $this->filters;

        $valueFiltered = $value;
        foreach ($chain as $filter) {
            $valueFiltered = call_user_func($filter, $valueFiltered);
        }

        return $valueFiltered;
    }
910137
public function filter($value)
    {
        if (!is_scalar($value)) {
            return $value;
        }

        $value = (string)$value;

        if ($this->options['encoding'] !== null) {
            $string = mb_strtolower($value, $this->options['encoding']);
            $upper = mb_strtoupper($string, $this->options['encoding']);
            preg_match('#(.)#us', $upper, $matches);
            $string = $matches[1] . mb_substr($string, 1, mb_strlen($string, $this->options['encoding']), $this->options['encoding']);
            return $string;
        }

        return ucfirst(strtolower($value));
    }
847395
public function setFieldFilter($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1\StructuredQuery_FieldFilter::class);
        $this->writeOneof(2, $var);

        return $this;
    }
59840
public function filter($value) {
        if (preg_match(Garp_Validate_DutchPostalCode::POSTALCODE_REGEXP, $value, $matches)) {
            return $matches[1] . strtoupper($matches[2]);
        }
        return $value;
    }
1138835
public function filter($value)
    {
        if (null === $value) {
            return null;
        }
        $this->checkValueIsValidOrThrowException($value);
        $matcher = key($value);
        $this->validateMatcherOrThrowException($matcher);
        $this->validateValueOrThrowException($value[$matcher]);

        return new Condition($matcher, $value[$matcher]);
    }
1098392
public function filter($value)
    {
        return in_array($value, $this->getList(), $this->getStrict()) ? $value : null;
    }
381359
private function filterVariablesUsedAsPlaceholders($string, array $variables)
    {
        if (empty($string)) {
            return $variables;
        }

        // array_filter() is not used because ARRAY_FILTER_USE_KEY requires PHP 5.6
        $filteredVariables = array();
        foreach ($variables as $key => $value) {
            if (false === strpos($string, '{'.$key.'}')) {
                $filteredVariables[$key] = $value;
            }
        }

        return $filteredVariables;
    }
625882
public function filter($value)
    {
        if (!is_string($value)) {
            return $value;
        }

        return json_decode($value, $this->assoc, $this->depth, $this->options);
    }
1235917
public function filter($var, $filters, $type = null)
    {
        if (!is_array($filters)) {
            $filters = $filters ? explode('|', $filters) : [];
        }

        $value = &$this->data[$var] ?? null;
        if ($value === null) {
            return null;
        }
        foreach ($filters as $key => $filter) {
            $params = explode(':', $filter);
            $filter = is_string($key) ? $key : array_shift($params);
            $filter = $this->filters[$filter] ?? function (&$data) use ($filter, $params) {
                $data = $filter($data, ...$params);
            };

            $errors = $filter($value, ...$params);
            if ($errors) {
                $this->errors[$var] = $errors;
                break;
            }
            if ($value === null) {
                return null;
            }
        }

        if ($type) {
            settype($value, $type);
        }

        return $value;
    }
367870
public function filter($value)
	{
		if (is_array($value) or (is_object($value) and $value instanceof \ArrayAccess))
		{
			return array_map([$this, 'filter'], $value);
		}

		return htmlentities($value, ENT_QUOTES | ENT_HTML5);
	}
1212002
public function match($var)
    {
        $ret = false;

        foreach ($this->_types as $type) {
            if (array_search($type, array("*", "mixed")) !== false) {
                $ret = true;
            } elseif (array_search($type, array("number", "numeric")) !== false) {
                $ret = is_numeric($var);
            } elseif (array_search($type, array("bool", "boolean")) !== false) {
                $ret = is_bool($var);
            } elseif ($type == "string") {
                $ret = is_string($var);
            } elseif ($type == "array") {
                $ret = is_array($var);
            } elseif ($type == "object") {
                $ret = is_object($var);
            } elseif ($type == "resource") {
                $ret = is_resource($var);
            } elseif ($type == "function") {
                $ret = is_callable($var);
            } elseif ($type == "scalar") {
                $ret = is_scalar($var);
            } else {
                $ret = is_a($var, $type);
            }

            if ($ret) {
                break;
            }
        }

        return $ret;
    }
431829
public function filter($value)
    {
        if ($value === null) {
            return $value;
        }

        if ($this->characters === null) {
            return trim($value);
        }

        return trim($value, $this->characters);
    }
1104365
public function filter($value)
    {
        if (null === $value) {
            return null;
        }
        $this->checkValueIsArrayOrThrowException($value);

        $return = [];
        foreach ($value as $header => $condition) {
            $return[$header] = $this->conditionFilter->filter($condition);
        }

        return $return;
    }