Filters the collection with the given closure, returning a new collection.

@return IssueCollection
504850
public function select(callable $filter)
    {
        if (! $this->collection) {
            return new IssueCollection();
        }

        $filtered = array_filter($this->collection, $filter);

        return new IssueCollection($filtered);
    }
1225940
public function createCollection()
    {
        $collectClass = $this->collectionClass();
        if ($collectClass === 'array') {
            return [];
        }

        if (!class_exists($collectClass)) {
            throw new RuntimeException(sprintf(
                'Collection class [%s] does not exist.',
                $collectClass
            ));
        }

        if (!is_subclass_of($collectClass, ArrayAccess::class)) {
            throw new RuntimeException(sprintf(
                'Collection class [%s] must implement ArrayAccess.',
                $collectClass
            ));
        }

        $collection = new $collectClass;

        return $collection;
    }
1264636
public function delete()
    {
        $status = $this->getMongoCollection()->drop();

        if ($status['ok'] != 1) {
            // check if collection exists
            if ('ns not found' !== $status['errmsg']) {
                // collection exist
                throw new Exception('Error deleting collection ' . $this->getName() . ': ' . $status['errmsg']);
            }
        }

        return $this;
    }
629078
public function resolveCollection($collection, $request = null)
    {
        return $collection->map(function ($item) use ($request) {
            return (new static($item))->toArray($request);
        })->all();
    }
1186902
private function &getCollection()
    {
        if (null === $this->collection) {
            $qb = $this->createAndFilterQueryBuilder($this->getEntityAlias());
            if ($this->isHydrationDisabled()) {
                $this->collection = $qb->getQuery()->getScalarResult();
            } else {
                $this->collection = $qb->getQuery()->getResult();
            }
        }
        return $this->collection;
    }
1318825
public function filter(\Closure $callback)
    {
        $collection = new static();

        foreach ($this as $element) {
            if ($callback($element)) {
                $collection->attach($element);
            }
        }

        return $collection;
    }
495194
public function onPreHandleRequestWithCollection(Collection $collection) {
        $output = new ArrayCollection();
        foreach ($collection as $current) {
            $output->add($current);
        }
        return $output;
    }
1017543
public function filter(\Closure $cClosure)
    {
        $sClassName      = get_class($this);
        $aFilteredValues = array();
        foreach ($this->values as $sKey => $mValue) {
            if (true === $cClosure($mValue, $sKey)) {
                $aFilteredValues[$sKey] = $mValue;
            }
        }

        return new $sClassName($aFilteredValues);
    }
953250
public function filter(Closure $callback): CollectionInterface
    {
        $array = array_filter(
            $this->toArray(),
            $callback,
            ARRAY_FILTER_USE_BOTH
        );

        return static::make(array_values($array));
    }
47933
protected function getCollection(): Collection
    {
        $conn = $this->connPool->getConnection();
        $database = $conn->defaultDatabase;
        $collection = $this->schema->collection;

        return $conn->getRawConnection()->$database->$collection;
    }
859156
public function fetch()
	{
		$this->filterByExtension();

		$results = Array();

		foreach ($this->finder as $file)
		{
			$config = new ConfigFile($this->fs, $this->fileInfo, $this->extracter);
			$config->load($file->getRealPath());
			$results[] = $config;
		}

		$this->finder = new Finder();

		return new CollectionResults($results);
	}
1135548
public function issues()
    {
        if (is_null($this->issueRequests)) {
            $this->issueRequests = new IssueRequests($this->client);
        }

        return $this->issueRequests;
    }
1259879
public function getCollection()
    {
        if (!$this->collection) {
            // gridfs
            if ($this->isFile) {
                $this->collection = $this->getConnection()->getMongoDB()->getGridFS($this->collectionName);
            // normal
            } else {
                $this->collection = $this->getConnection()->getMongoDB()->selectCollection($this->collectionName);
            }
        }

        return $this->collection;
    }
480582
public function allCollections($wrap = false)
    {
        $collections = $this->database->listCollections();

        if (! $wrap) {
            return $collections;
        }

        return array_map(
            function ($collection) {
                return new Collection($collection);
            },
            $collections
        );
    }
1210608
public function getFilters(): Collection
    {
        $filters = collect();
        foreach ($this->filters() as $filter) {
            $filter = new $filter($this);
            $filters->push($filter);
        }

        return $filters;
    }
1209304
public function collections()
    {
        $uri = $this->uri->withPath($this->uri->getPath() . ':listCollectionIds');
        $value = $this->client->post($uri, null);
        $collections = [];

        foreach ($value['collectionIds'] as $id) {
            $collections[] = $this->collection($id);
        }

        return $collections;
    }
1140871
protected function retrieveCollection()
    {
        $cache = new FilesystemAdapter($this->namespace);
        $item = $cache->getItem('collection');

        $collection = null;
        if ($item->isHit()) {
            $collection = $item->get('collection');
        }

        if (empty($collection) || !$collection instanceof ValuesCollection) {
            $collection = new ValuesCollection();
        }

        return $collection;
    }