Applies a closure to a copy of all data in the collection
and returns the result.

@param  Closure $closure The closure to apply.
@return mixed            Returns the set of filtered values inside a `Collection`.
195740
public function map($closure)
    {
        $data = [];
        foreach ($this as $val) {
            $data[] = $closure($val);
        }
        return new Collection(compact('data'));
    }
307206
public function each(Closure $closure)
    {
        foreach ($this->stack as &$item) {
            $closure($item);
        }

        return $this;
    }
1130100
public function filter(\Closure $callback = null) : Collection
    {
        if ($callback) {
            return static::create(array_filter($this->data, $callback));
        }

        return static::create(array_filter($this->data));
    }
268377
public function ifTrue(\Closure $closure = null)
    {
        if (null === $closure) {
            $closure = function ($v) { return true === $v; };
        }

        $this->ifPart = $closure;

        return $this;
    }
754581
public function after($number, Closure $closure)
    {
        $hash = spl_object_hash((object) $closure);

        if (isset ($this->delayed[$hash]))
        {
            $closure = $this->delayed[$hash];

            return $closure();
        }

        $this->delayed[$hash] = function() use($number, $closure)
        {
            static $tries = 0;

            $tries += 1;

            if ($tries === $number)
            {
                return $closure();
            }
        };
    }
1318825
public function filter(\Closure $callback)
    {
        $collection = new static();

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

        return $collection;
    }
27407
final protected function ensureAccessible(\Closure $closure)
    {
        return \Closure::bind($closure, null, $this->property->getAccessibility()->getDeclaredClass());
    }
819277
public function serializeClosure(\Closure $closure)
    {
        if ($this->isSingle()) {
            return SerializeHelper::component()->serializeClosure($closure);
        }

        return null;
    }
528171
public function notFilter(Closure $closure)
    {
        $query = $this->newNestedInstance($closure);

        $filter = $this->grammar->compileNot($query->getQuery());

        return $this->rawFilter($filter);
    }
338216
function reduce(callable $closure, $carry = null) {
        foreach($this->data as $val) {
            $carry = $closure($carry, $val);
        }
        
        return $carry;
    }
701398
public function handle(Closure $closure)
    {
        $this->strict(
            \call_user_func($closure, $this->getMessage(), [$this, 'fail'])
        );

        return $this->toResponse();
    }
687429
public function apply($closure)
    {
        foreach ($this as $key => $val) {
            $this->offsetSet($key, $closure($val, $key, $this));
        }
        return $this;
    }
1185091
private function runViaLaravelCollection($closure, $method = null)
    {
        $collection = new TightencoCollect($this->items);

        $result = $closure($collection);

        if (!$this->methodMustReturnArray($method)) {
            $result = $this->coollectizeItems($result);
        }

        $this->items = $collection->all();

        return $result;
    }
943326
function some(callable $closure) {
        foreach($this->data as $key => $val) {
            if($closure($val, $key)) {
                return true;
            }
        }
        
        return false;
    }
1060655
private function guess(\Closure $closure): Guess
    {
        $guesses = [];

        foreach ($this->guessers as $guesser) {
            if ($guess = $closure($guesser)) {
                $guesses[] = $guess;
            }
        }

        return Guess::getBestGuess($guesses);
    }
1343782
public function orFilter(Closure $closure)
    {
        $query = $this->newNestedInstance($closure);

        $filter = $this->grammar->compileOr($query->getQuery());

        return $this->rawFilter($filter);
    }
1158486
public function filter(Closure $filter)
    {
        $filtered = clone $this;

        $filtered->models = Objects::filter($filtered->models, $filter);

        return $filtered;
    }