Remembers the return value of the callback and returns that
if available on next call.
@param $key string
@param callable $callBack
@return mixed
762444
public function remember(string $key, callable $callBack)
    {
        $existing = $this->get($key);
        if ($existing !== null) {
            return $existing;
        }

        $result = $callBack();
        return $this->put($key, $result);
    }
93393
public function retry(callable $callback)
    {
        $userHandlerCloned = $providerHandlerCloned = false;

        return \ScriptFUSION\Retry\retry(
            $this->maxFetchAttempts,
            $callback,
            function (\Exception $exception) use (&$userHandlerCloned, &$providerHandlerCloned) {
                // Throw exception instead of retrying, if unrecoverable.
                if (!$exception instanceof RecoverableConnectorException) {
                    throw $exception;
                }

                // Call provider's exception handler, if defined.
                if ($this->resourceFetchExceptionHandler) {
                    self::invokeHandler($this->resourceFetchExceptionHandler, $exception, $providerHandlerCloned);
                }

                // Call user's exception handler.
                self::invokeHandler($this->fetchExceptionHandler, $exception, $userHandlerCloned);
            }
        );
    }
994845
protected static function callback($callback)
    {
        if( is_string($callback) && ! is_callable($callback) )
        {
            return self::controllerCallback($callback);
        }

        return $callback;
    }
141205
public function each(callable $callback)
    {
        foreach ($this->nodes as $index => $node) {
            $return_value = \call_user_func($callback, $node, $index);

            if ($return_value === false) {
                break;
            }
        }

        return $this;
    }
86744
protected function checkAndReturnCallable($callback)
    {
        if (is_string($callback)) {
            return function ($app) use ($callback) {
                return $app($callback);
            };
        }

        if (!is_callable($callback)) {
            $type = is_object($callback) ? get_class($callback) : gettype($callback);
            throw new InvalidArgumentException("Passed argument of type $type is not callable");
        }

        return $callback;
    }
1053815
public function first(callable $callback = null, $default = null)
    {
        if (is_null($callback)) {
            return empty($this->items) ? $default : reset($this->items);
        }

        foreach ($this->items as $key => $value) {
            if (call_user_func($callback, $value, $key)) {
                return $value;
            }
        }

        return $default;
    }
149438
public function select ($callback)
	{
		if(!is_callable($callback)) {
			throw new \InvalidArgumentException('Invalid (not callable) callback given');
		}

		return $this->map(function ($v) use ($callback) {
			if ($callback($v)) {
				return $v;
			}
		});
	}
1188149
public function getOnce($key, Closure $callback)
    {
        if ($this->has($key) !== false) {
            return $this->session[$key];
        } else {
            $value = $callback();
            $this->set($key, $value);
            return $value;
        }
    }
503934
protected function getCallback($callback, array $parameters)
    {
        if ($callback instanceof Closure) {
            return $this->createCallableCallback($callback, $parameters);
        } elseif (is_string($callback)) {
            return $this->createStringCallback($callback, $parameters);
        } else {
            return;
        }
    }
327198
public function get($callback = null)
    {
        $result = $this->acquire();

        if ($result && is_callable($callback)) {
            try {
                return $callback();
            } finally {
                $this->release();
            }
        }

        return $result;
    }
264540
protected function sear($key, callable $callback)
    {
        if (is_null($value = $this->cache->get($key))) {
            $this->cache->forever($key, $value = $callback());
        }

        return $value;
    }
372859
public function remember(string $key, \Closure $getValueCallback, int $expire = null)
    {
        if (($fromCache = $this->get($key)) !== false) {
            return $fromCache;
        }

        $this->set($key, $value = $getValueCallback(), $expire);

        return $value;
    }
956006
public function map ($callback)
	{
		if(!is_callable($callback)) {
			throw new \InvalidArgumentException('Invalid (not callable) callback given');
		}

		$result = new self();

		for ($i = 0; $i < $this->count(); $i++) {
			$value = $callback($this->storage[$i]);

			if (null !== $value) {
				$result->push($value);
			}
		}

		return $result;
	}
259169
public function remember($key, \Closure $callback)
    {
        if (! $this->cacheIsEnabled()) {
            return $callback();
        }

        $key = config('health.cache.key').$key;

        $this->flush(false, $key);

        return IlluminateCache::remember($key, $this->getMinutes(), $callback);
    }
1181264
public function last(callable $callback = null, $default = null)
    {
        if (is_null($callback)) {
            if (!empty($this->items)) {
                return end($this->items);
            }
        }
        else {
            foreach (array_reverse($this->items, true) as $key => $value) {
                if (call_user_func($callback, $value, $key)) {
                    return $value;
                }
            }
        }

        return $default instanceof Closure ? $default() : $default;
    }
984564
public function getContent($key, $callback)
    {
        if ($this->nestedContentFilter) {
            return $this->nestedContentFilter->getContent($key, $callback);
        } else {
            return call_user_func($callback);
        }
    }
195830
public function getCallbackObject($callback)
    {
        foreach ($this->callbacks as $object) {
            if ($this->callbacks[$object] === $callback) {
                return $object;
            }
        }
    }