Return a new collection by filtering data within the current collection.

@param mixed $filter

@return ArrayObjectInterface
425292
public function filter($filter): ArrayObjectInterface
    {
        return \is_callable($filter, true) ? $this->filterCallback($filter) : $this->filterConditions($filter);
    }
18397
public function filter(ODataQueryFilterInterface $filter = NULL) {
        if (isset($filter)) {
            $this->setFilter($filter);
            return $this;
        }
        return $this->getFilter();
    }
1345549
public function filter($filter)
    {
        if (is_array($filter)) {
            $filter = new GridFilter($filter);
        }

        if ($filter instanceof FilterSpecification) {
            $filter = new GridFilter($filter->asFilter());
        }

        $this->filter = $filter;

        return $this;
    }
895267
public function getParent($filter = null)
    {
        $parentID = $this->owner->ParentID;
        if (empty($parentID)) {
            return null;
        }
        $baseClass = $this->owner->baseClass();
        $idSQL = $this->owner->getSchema()->sqlColumnForField($baseClass, 'ID');
        return DataObject::get_one($baseClass, [
            [$idSQL => $parentID],
            $filter
        ]);
    }
336671
public function addFilter($filter)
    {
        if (!$filter instanceof FilterInterface) {
            if (!is_callable($filter)) {
                throw new \InvalidArgumentException('Filter should be callable or ' . FilterInterface::class);
            }

            $filter = new CallbackFilter($filter);
        }

        $this->filters[] = $filter;

        return $this;
    }
896280
public static function getOrders($filter = array())
    {
        $filter = Filter::create($filter);
        return self::getCollection('/orders' . $filter->toQuery(), 'Order');
    }
310717
public function select(array $filter, array $sorting = [])
    {
        $this->filter = $filter;
        $this->sorting = $sorting;
        $this->prefetch = false;
        $this->items = null;

        return $this;
    }
365006
public function getFilter($filter)
    {
        $result = null;

        if(isset($this->__filters[$filter])) {
            $result = $this->__filters[$filter];
         }

        return $result;
    }
14398
public function getList($filter = array()) {
        $res = array();
        $dbres = \CAgent::GetList(array("MODULE_ID" => "ASC"), $filter);
        while ($item = $dbres->Fetch()) {
            $res[] = $item;
        }
        return $res;
    }
49453
public function withFilter(Filter $filter)
    {
        if ($this->value->isNull()) {
            return null;
        }

        return $this->applyFilter($filter);
    }
970149
public static function filter(array $data, $filter): array
    {
        if (!$filter) {
            return $data;
        }

        if (is_callable($filter)) {
            return array_filter($data, $filter);
        }

        if ($filter & self::FILTER_NULL) {
            return array_filter(
                $data,
                function ($value) {
                    return $value !== null;
                }
            );
        } elseif ($filter & self::FILTER_EMPTY) {
            return array_filter(
                $data,
                function ($value) {
                    return isset($value[0]);
                }
            );
        } elseif ($filter & self::FILTER_PHP) {
            return array_filter($data);
        }

        return $data;
    }
259360
public function findAll($re, $filter = null) {
        $result = array();
        $this->each(function($context) use ($re, $filter, &$result) {
            $context->findAll($re, $filter)->each(
                function($context) use (&$result) {
                    $result[] = $context;
                }
            );
        });

        return new self($result);
    }
1012283
public function filter($filter = null)
    {
        if (is_null($filter)) {
            return $this->filter;
        } else {
            $this->filter = $filter;
        }
    }
18969
public function addFilter($filter)
    {
        if (!($filter instanceof FilterInterface) && !is_callable($filter)) {
            $filter = FilterHelper::create($filter);
        }

        $this->filter->addFilter($filter);

        return $this;
    }
109250
public function count($filter = null)
    {
        if (is_null($filter)) {
            return $this->_countObjectsInCollection();
        } else if (is_string($filter)) {
            json_decode($filter);
            $isJson = (json_last_error() === JSON_ERROR_NONE) ? true :false;
            if ($isJson) {
                $filter = new Filter($filter);
                return $this->_countObjectsInCollectionByFilter($filter);
            }
        } else if (is_object($filter) && $filter instanceof Filter) {
            return $this->_countObjectsInCollectionByFilter($filter);
        }
        return 0;
    }
576940
public function getUser($filter)
    {
        $iterator = $this->anyDataSet->getIterator($filter);
        if (!$iterator->hasNext()) {
            return null;
        }

        return $this->createUserModel($iterator->moveNext());
    }
1013669
public function filter($filter)
    {
        $callback = is_array($filter) ? $this->_filterFromArray($filter) : $filter;
        $data = array_filter($this->_data, $callback);
        return new static($data);
    }