Match a single filter, i.e. [foo]. It matches only if all filter parts match.

@param object $element
@param string $filter
@return boolean true if $element matches filter, false otherwise
559653
protected function matchesFilter($element, $filter)
    {
        if (isset($filter['IdentifierFilter']) && !$this->matchesIdentifierFilter($element, $filter['IdentifierFilter'])) {
            return false;
        }
        if (isset($filter['PropertyNameFilter']) && !$this->matchesPropertyNameFilter($element, $filter['PropertyNameFilter'])) {
            return false;
        }

        if (isset($filter['AttributeFilters'])) {
            foreach ($filter['AttributeFilters'] as $attributeFilter) {
                if (!$this->matchesAttributeFilter($element, $attributeFilter)) {
                    return false;
                }
            }
        }
        return true;
    }
675629
protected function matchesAttributeFilter($element, array $attributeFilter)
    {
        if ($attributeFilter['PropertyPath'] !== null) {
            $value = $this->getPropertyPath($element, $attributeFilter['PropertyPath']);
        } else {
            $value = $element;
        }
        $operand = null;
        if (isset($attributeFilter['Operand'])) {
            $operand = $attributeFilter['Operand'];
        }

        return $this->evaluateOperator($value, $attributeFilter['Operator'], $operand);
    }
1134633
public function is($filter): bool
    {
        if ($filter instanceof Entity) {
            return $this->isSameAsEntity($filter);
        }

        if (is_associative_array($filter)) {
            return $this->matchesFilter($filter);
        }

        return $this->matchedId($filter);
    }
310006
protected function matchedId($filter): bool
    {
        if (!$this instanceof IdentifiableEntity) {
            return false;
        }

        $id = $this->getId();

        return is_scalar($id) && is_scalar($filter) ? (string)$id === (string)$filter : $id === $filter;
    }
287879
public function remove($element)
    {
        $hash = $this->hash($element);
        if (isset($this->hashTable[$hash])) {
            $i = array_search($element, $this->hashTable[$hash], true);
            if ($i !== false) {
                unset($this->hashTable[$hash][$i]);
                return true;
            }
        }
        return false;
    }
1165377
public function match($key, $value, $bool, $filter = false, array $params = []) {
        if (is_array($key)) {
            return $this->multiMatch($key, $value, $bool, $filter, $params);
        }
        if (is_array($value)) {
            return $this->matches($key, $value, $bool, $filter, $params);
        }
        $this->addBool($this->makeFilteredQuery(["match" => [$key => ["query" => $value] + $params]], $filter), $bool, $filter);
        return $this;
    }
831263
public static function addFilter($filter, $callback = null)
    {
        if (is_array($filter)) {
            $filters = $filter;
            foreach ($filters as $key => $filter) {
                if (is_numeric($key)) {
                    $key = $filter;
                }
                self::addFilter($key, $filter);
            }

            return true;
        } elseif (is_string($filter) && class_exists($filter, false) && is_subclass_of($filter, 'FilterCollection')) {
            foreach (get_class_methods($filter) as $f) {
                if (is_callable(array($filter, $f))) {
                    self::$filters[$f] = array($filter, $f);
                }
            }

            return true;
        }
        if (is_null($callback)) {
            $callback = $filter;
        }

        if (!is_callable($callback)) {
            return false;
        }
        self::$filters[$filter] = $callback;
    }
1363592
public function filter($filter) {
		if (!in_array($filter, array(self::FILTER_NEGATE, self::FILTER_GRAYSCALE)))
			return false;
		imagefilter($this->resource, $filter);
		return $this;
	}
104528
public function setFilter($filter)
    {
        parent::setFilter($filter);

        $this->userOptions['value'] = $this->validator->arrayGet($filter, 'value', '');

        //if it isn't null, we have to check the 'true'/'false' string
        if ($this->userOptions['value'] !== '') {
            $this->userOptions['value'] = $this->userOptions['value'] === 'false' || !$this->userOptions['value'] ? 0 : 1;
        }
    }
1101148
protected function isInstanceFilter($filter)
	{
		if (is_string($filter) && starts_with($filter, '@'))
		{
			if (method_exists($this, substr($filter, 1))) return true;

			throw new \InvalidArgumentException("Filter method [$filter] does not exist.");
		}

		return false;
	}
756816
public function remove($element) : bool
    {
        if (!$this->contains($element)) {
            return false;
        }
        $index = array_search($element, $this->elements, true);
        unset($this->elements[$index]);

        return !$this->contains($element);
    }
256587
public function hasFilter($filter)
    {
        $key = is_callable($filter) ? 0 : 1;

        foreach ($this->filters as $tuple) {
            if ($tuple[$key] === $filter) {
                return true;
            }
        }

        return false;
    }
50833
public function containsAll($elements)
    {
        foreach ($elements as $element) {
            if (false === $this->contains($element)) {
                return false;
            }
        }

        return true;
    }
516762
public static function filterByScope($filter)
    {
        $operator = Arr::get($filter, 'operator');
        $method = Arr::get($filter, 'method');
        $source = Arr::get($filter, 'settings.source');
        $arguments = Arr::get($filter, 'arguments');
        $value_one = Arr::get($filter, 'value_one');
        $value_two = Arr::get($filter, 'value_two');
        $settings = Arr::get($filter, 'settings');
        $positive = Arr::get($filter, 'positive');

        if (Arr::has($filter, 'settings.source')) {
            $model = Arr::get($filter, 'settings.model');

            $method_transform = 'transform'.Str::studly($source).'Value';

            if (method_exists($model, $method_transform)) {
                $value_one = $model->$method_transform($value_one);
            }

            $method_lookup = 'scope'.Str::studly($source);

            if (!method_exists($model, $method_lookup)) {
                return false;
            }

            $method = Str::camel($source);
            $arguments = [$value_one];
        }

        return [
            'operator'  => $operator,
            'method'    => $method,
            'arguments' => $arguments,
            'value_one' => $value_one,
            'value_two' => $value_two,
            'settings'  => $settings,
            'positive'  => $positive,
        ];
    }
1244649
public function matches_all_filters(\context $context) {
        $filters = helper::get_all_filters();

        // All filters must match.
        // If any one filter fails to match, we return false.
        foreach ($filters as $filterclass) {
            if (!$filterclass::filter_matches($this, $context)) {
                return false;
            }
        }

        return true;
    }
644047
protected function isElementValid($element) : bool
    {
        return is_a($element, $this->getType()) || is_subclass_of($element, $this->getType());
    }
1227208
public function containsAnyOf(array $elements): bool
    {
        if (!is_scalar($this->value) || null === $this->value) {
            return false;
        }

        foreach ($elements as $needle) {
            if (is_bool($needle) && $this->value === $needle) {
                return true;
            } elseif (!is_bool($needle) && ($this->value === $needle || (is_string($this->value) && false !== strpos($this->value, (string) $needle)))) {
                return true;
            }
        }

        return false;
    }