Run a filter over each of the items.

@param  callable|null $callback
@return CollectionInterface
178117
public function filter(callable $callback = null): CollectionInterface
    {
        if (!$callback) {
            $callback = function ($item) {
                return (bool)$item;
            };
        }

        return $this->wrap(function (Iterator $data) use ($callback) {
            foreach ($data as $key => $item) {
                if ($callback($item, $key)) {
                    yield $key => $item;
                }
            }
        });
    }
510997
public function filter(callable $callback): self
    {
        $set = clone $this;
        $set->internal_set = $this->internal_set->filter($callback);

        return $set;
    }
33171
public function children(callable $callback = NULL) {
    $matches = [];
    foreach ($this->nodes as $node) {
      if ($node instanceof ParentNode) {
        $matches = array_merge($matches, $node->children($callback)->nodes);
      }
    }
    return new NodeCollection($matches);
  }
446148
public function map(callable $callback): ArrayCollection
    {
        $items = [];

        foreach ($this->items as $key => $value) {
            $items[$key] = $callback($value, $key);
        }

        return new static($items);
    }
1365357
public function keyBy(callable $callback): ArrayCollection
    {
        $items = [];

        foreach ($this->items as $key => $value) {
            $items[$callback($value, $key)] = $value;
        }

        return new static($items);
    }
383897
public function filter(Closure $callback)
    {
        $filtered_map = new static;

        foreach ($this->items as $key => $item) {
            if ($callback($item) === true) {
                $filtered_map->setItem($key, $item);
            }
        }

        return $filtered_map;
    }
907375
public function make(string $name, ?Closure $callback = null) : Collection {
        return $this->collection($name, $callback);
    }
62101
public function filter(callable $callback = null)
    {
        if ($callback) {

            return new static(ArrayHelper::where($this->items, $callback));
        }

        return new static(array_filter($this->items));
    }
463483
public function find(callable $callback) {
    $matches = [];
    foreach ($this->nodes as $node) {
      if ($node instanceof ParentNode) {
        $matches = array_merge($matches, $node->find($callback)->nodes);
      }
    }
    return new NodeCollection($matches);
  }
1110130
public function map(callable $callback = null)
	{
		return $callback ? array_map($callback, $this->list) : $this->list;
	}
789140
public function every( callable $callback, $passOnEmpty = true )
    {
        foreach( $this->collection as $entity ) {
            if( !call_user_func( $callback, $entity) ) {
                return false;
            }
        }
        return $this->collection ? true :  (bool) $passOnEmpty;
    }
1297019
public function reduce(callable $callback, $initial = null): Collection
    {
        return new Collection(array_reduce($this->items, $callback, $initial));
    }
416927
public function filter(callable $callback = null)
    {
        if ($callback === null) {
            return new static(\array_filter($this->all()));
        }

        return new static(\array_filter($this->all(), $callback));
    }
699329
public function some(callable $callback) {
		$match = false;
		foreach ($this->collection as $element) {
			$match = $match || $callback($element);
		}

		return $match;
	}
22674
public function filter(callable $callback): self
    {
        $collection = Factory::create();
        $index      = 0;
        foreach ($this->items as $key => $value) {
            if ($callback($value, $key, $index++)) {
                $collection->set($key, $value);
            }
        }

        return $collection;
    }
532949
public function filter(callable $callback = null)
    {
        if (!is_null($callback)) {
            return new static(
                $this->wye,
                array_filter($this->items, $callback, ARRAY_FILTER_USE_BOTH)
            );
        }

        return new static($this->wye, array_filter($this->items));
    }
875414
public function filterByCallback($callback)
    {
        if (!is_callable($callback)) {
            throw new LogicException(sprintf(
                "SS_Filterable::filterByCallback() passed callback must be callable, '%s' given",
                gettype($callback)
            ));
        }

        $output = static::create();

        foreach ($this as $item) {
            if (call_user_func($callback, $item, $this)) {
                $output->push($item);
            }
        }

        return $output;
    }