Prepare an array of pattern / callbacks before
caching them.

@param array|Closure $callbacks
@return array
493938
protected function prepareCallbacks($callbacks)
    {
        if (is_array($callbacks)) {
            foreach ($callbacks as &$callback) {
                $callback['callback'] = $this->serializeClosure($callback['callback']);
            }
        } else {
            $callbacks = $this->serializeClosure($callbacks);
        }

        return $callbacks;
    }
1094266
public function map(\Closure $callback)
    {

        $this->_items = array_map($callback, $this->_items);

        return $this;
    }
1171018
public function indexes(Closure $callback)
    {
        $indexes = new Query\Indexes($this->collection);
        $callback($indexes);

        return $this;
    }
1066566
public function map($callback) : ArrayList
    {
        $values = $this->_map($callback);
        $this->setValues($values);
        return $this;
    }
581849
public function findCallback(Closure $callback, $columns = ['*'])
    {
        /** @var EloquentBuilder $result */
        $result = $callback( $this->query() );

        $this->checkValidCustomCallback($result);

        return $result->first($columns);
    }
618738
public function missing(Closure $callback)
	{
		$this->error(function(NotFoundHttpException $e) use ($callback)
		{
			return call_user_func($callback, $e);
		});
	}
217257
public function preprocess(callable $callback)
    {
        if ($callback instanceof Closure) {
            $callback = $callback->bindTo($this, get_class($this));
        }

        $this->getPreprocessor()->register($callback);
        return $this;
    }
1024553
public static function map(array $arr, callable $callback): array
    {
        $arrResult = [];

        foreach ($arr as $index => $value) {
            $arrResult[] = $callback($value, $index);
        }

        return $arrResult;
    }
750076
public function setCallback($callback)
    {
        // If the provided $value is not a closure, make it one now for easy resolution.
        if (!is_callable($callback)) {
            $callback = function () use ($callback) {
                return $callback;
            };
        }

        if ($this->protected) {
            return $this;
        }

        $this->callback = $callback;

        return $this;
    }
977989
public static function make($cache, \Closure $callback)
    {
        // Return Closure callback
        if (array_key_exists($cache, static::$drivers)) {
            return static::getCacheDriver($callback, $cache);
        }

        throw new \RuntimeException('Cache driver not found!');
    }
31327
public static function hydrateCollection(array $callbacks)
    {
        $hydrated = [];

        foreach ($callbacks as $callback) {
            $hydrated[] = self::hydrate($callback);
        }

        return $hydrated;
    }
277111
private function performCallbackOnCachedPersister(callable $callback)
    {
        if (! $this->hasCache) {
            return;
        }

        foreach (array_merge($this->entityPersisters, $this->collectionPersisters) as $persister) {
            if ($persister instanceof CachedPersister) {
                $callback($persister);
            }
        }
    }
629598
public function each( \Closure $callback )
	{
		foreach( $this->items as $name => $properties )
		{
			if( $callback($properties, $name) === false )
			{
				break;
			}
		}

		return $this;
	}
1321626
public static function where($array, \Closure $callback)
        {
            $filtered = array();

            foreach ($array as $key => $value) {
                if (call_user_func($callback, $key, $value)) {
                    $filtered[$key] = $value;
                }
            }

            return $filtered;
        }
1059650
protected function parseCallbacks(array $callbacks)
    {
        foreach (array('before', 'after') as $position) {
            // Remove disabled callbacks
            foreach ($callbacks[$position] as $i => $callback) {
                if ($callback['disabled']) {
                    unset($callbacks[$position][$i]);
                }
            }

            // Order callbacks according to priority index
            uasort($callbacks[$position], function($a, $b) {
                if ($a['priority'] === $b['priority']) {
                    return 0;
                }
                return $a['priority'] < $b['priority'] ? -1 : 1;
            });
        }

        return $callbacks;
    }
477765
public function filter(\Closure $callback)
    {
        $result = [];
        foreach ($this->value as $entity) {
            if ($callback($entity)) {
                $result[] = $entity;
            }
        }

        return $result;
    }
1305866
protected function cacheResults($name, Closure $callback)
    {
        return Cache::remember('cache::' . $name, $this->minutes, $callback);
    }