@param mixed              $items
@param IndexQueryFilter[] $filters

@return array
553033
public function filter(array $items, array $filters): array
    {
        if (empty($filters)) {
            // no filters means return all items
            return $items;
        }

        return array_filter($items, function ($item) use ($filters) {
            foreach ($filters as $filter) {
                $value = $this->extractValue($item, $filter->getField());
                if (!$this->valueMatchesFilter($value, $filter)) {
                    // all filters must pass so any failure means we
                    // can stop checking this item immediately.
                    return false;
                }
            }

            return true;
        });
    }
58981
private function buildQuery($filters=array())
	{
		$entries = self::all();

		$m = $entries->getTableName();
		$u = '#__users';

		if (isset($filters['group_id']) && $filters['group_id'] != 0)
		{
			$entries
				->select($m . '.*,' . $u . '.name')
				->join($u, $u . '.id', $m . '.created_by', 'inner');
		}
		else
		{
			$r = Recipient::blank()->getTableName();

			$entries
				->select($m . '.*,' . $u . '.name')
				->join($r, $r . '.mid', $m . '.id', 'inner')
				->join($u, $u . '.id', $r . '.uid', 'inner');
		}

		if (isset($filters['created_by']) && $filters['created_by'] != 0)
		{
			$entries->whereEquals('created_by', $filters['created_by']);
		}
		if (isset($filters['daily_limit']) && $filters['daily_limit'] != 0)
		{
			$start = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y'))) . " 00:00:00";
			$end   = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y'))) . " 23:59:59";

			$entries->where('created', '>=', $start);
			$entries->where('created', '<=', $end);
		}
		if (isset($filters['group_id']) && $filters['group_id'] != 0)
		{
			$entries->whereEquals('group_id', (int)$filters['group_id']);
		}

		return $entries;
	}
70788
public function listing($filters)
	{
		$listing = $this->smalldb->createListing($filters);
		return [
			'items' => array_values($listing->fetchAll()),	// Order of object's properties not guaranteed in JS
			'processed_filters' => $listing->getProcessedFilters(),
		];
	}
386239
public function filter(array $filters)
	{
		foreach ($filters as $filter) {
			if ($filter->isValueSet()) {
				if ($filter->hasConditionCallback()) {
					$data = (array) call_user_func_array(
						$filter->getConditionCallback(),
						[$this->data, $filter->getValue()]
					);
					$this->setData($data);
				} else {
					$data = array_filter($this->data, function ($row) use ($filter) {
						return $this->applyFilter($row, $filter);
					});
					$this->setData($data);
				}
			}
		}

		return $this;
	}
86522
public function all($filters = array())
	{
		$query = $this->connection->getQuery()
			->select('session_id')
			->select('client_id')
			->select('guest')
			->select('time')
			->select('data')
			->select('userid')
			->select('username')
			->select('ip')
			->from('#__session');

		$max = '';
		if (isset($filters['distinct']) && $filters['distinct'] == 1)
		{
			$query->select('MAX(time)', 'time');
		}

		if (isset($filters['guest']))
		{
			$query->whereEquals('guest', $filters['guest']);
		}

		if (isset($filters['client']))
		{
			if (!is_array($filters['client']))
			{
				$filters['client'] = array($filters['client']);
			}

			$query->whereIn('client_id', $filters['client']);
		}

		if (isset($filters['distinct']) && $filters['distinct'] == 1)
		{
			$query
				->group('session_id')
				->group('userid')
				->group('client_id');
		}

		$query->order('time', 'desc');

		$this->connection->setQuery($query->toString());
		return $this->connection->loadObjectList();
	}
333989
private function prepareFilters(array $filters = [])
    {
        /** @var \common_session_Session $session */
        $session  = common_session_SessionManager::getSession();
        $timeZone = new DateTimeZone($session->getTimeZone());
        $utc      = new DateTimeZone('UTC');

        $result = [];

        foreach ($filters as $name => $value) {
            if (!empty($value)) {
                switch ($name) {
                    case 'from':
                        $from     = new DateTimeImmutable($filters['from'], $timeZone);
                        $result[] = ['occurred', '>', $from->setTimezone($utc)->format(DateTime::ISO8601)];
                        break;
                    case 'to':
                        $to       = new DateTimeImmutable($filters['to'], $timeZone);
                        $result[] = ['occurred', '<=', $to->setTimezone($utc)->format(DateTime::ISO8601)];
                        break;
                    default:
                        $result[] = [$name, 'LIKE', "%$value%"];
                }
            }
        }

        return $result;
    }
1016770
public function fromItems(array $items): array
    {
        $objects = [];
        foreach ($items as $item) {
            $objects[] = $this->fromItem($item);
        }

        return $objects;
    }
270341
public static function indexBy($items, $key)
    {
        $array = array();

        foreach ($items as $item) {
            $array[self::getValue($item, $key)] = $item;
        }

        return $array;
    }
275062
protected function filterItems(array $items)
    {
        $data = [];

        foreach ($items as $item) {
            $item = trim($item);

            if (empty($item)) {
                continue;
            }

            $item = $this->removeChar($item, '[', ']');

            if ($this->itemIsSerialized($item)) {
                $data[] = unserialize($item);
                continue;
            }

            if (strpos($item, '=>') !== false) {
                $element = explode('=>', $item);
                $element[0] = trim($element[0]);
                $element[1] = trim($element[1]);

                $key = $this->removeChar($element[0], ['"', "'"], ['"', "'"]);
                $val = $this->removeChar($element[1], ['"', "'"], ['"', "'"]);

                $data[$key] = $val;
            } else {
                $data[] = $this->removeChar($item, ['"', "'"], ['"', "'"]);
            }
        }

        return $data;
    }
283203
private static function validateFilters($filters, $settings)
    {
        if (!is_array($filters)) {
            $filters = [$filters];
        }

        // Each fitler.
        foreach ($filters as $index => &$filter) {

            // Check this item.
            $filter = self::validateFilterItem($filter, $settings);

            // Remove if invalid.
            if (empty($filter)) {
                unset($filters[$index]);
            }
        }

        return $filters;
    }
414419
public function filters($filters)
    {
        if(!is_array($filters)){
            throw new \RuntimeException('Filters not specified', ResourceException::FILTERS_NOT_SPECIFIED);
        }

        $this->filters = json_encode($filters);

        return $this;
    }
1358115
protected static function doFindFilters(array $filters, array $enabledFilters, $all)
    {
        $reactivateFilters = [];

        foreach ($enabledFilters as $name => $filter) {
            if (\in_array($name, $filters, true) || $all) {
                $reactivateFilters[] = $name;
            }
        }

        return $reactivateFilters;
    }
307799
public function listListings(array $filters = [])
    {
        $query = '';

        if ($this->config->products) {
            $filters['product__id'] = $this->config->products;
        }

        if ($filters) {
            $query = '?' . preg_replace('/%5B[0-9]+%5D/simU', '', http_build_query($filters));
        }

        $body = $this->sendRequest('GET', '/listings' . $query);

        /** @var Listing[] $models */
        $models = Model::modelize('listings', json_decode($body));
        foreach ($models as $index => $model) {
            $models[$index]->requestProcessor = $this;
        }

        return $models;
    }
938246
public function addFilter($filters)
    {

        $filters = is_array($filters) ? $filters : func_get_args();

        foreach ($filters as $filter) {

            $this->filters[] = $filter;
        }

        return $this;
    }
715799
public function setFilters($filters)
    {
        if ($filters === null)
            $filters = [];
        else if (!is_array($filters))
            throw new \Exception('Filters should be null or array');

        foreach ($filters as $column => $filter) {
            $found = [];
            foreach ($this->getColumns() as $id => $params) {
                if ($id == $column) {
                    foreach ($filter as $name => $value) {
                        if (in_array($name, $params['filters']))
                            $found[$name] = $value;
                    }
                    break;
                }
            }

            if (count($found) > 0)
                $filters[$column] = $found;
            else
                unset($filters[$column]);
        }

        $this->filters = $filters;
        return $this;
    }
985283
public function getRecords($filters = array())
	{
		$entries = self::all();

		$c = $entries->getTableName();
		$e = '#__extensions';

		$entries
			->select($c . '.*,' . $e . '.name')
			->join($e, $e . '.element', $c . '.component', 'inner')
			->whereEquals($e . '.type', 'component');

		if (isset($filters['component']) && $filters['component'])
		{
			$entries->whereEquals($e . '.element', $filters['component']);
		}

		return $entries
			->ordered($c . '.component', 'asc')
			->rows();
	}
122475
public function filters($ext, $filters = null)
    {
        if ($filters === null) {
            if (isset($this->_data[$ext][self::FILTERS])) {
                return $this->_data[$ext][self::FILTERS];
            }
            return [];
        }
        $this->_data[$ext][self::FILTERS] = $filters;
    }