Get head element of the array

@param callable $callback

@return mixed
341296
private function _first(callable $callback = null)
    {
        $values = $this->getValues();
        if ($callback){
            foreach($values as $key => $value){
                if ($callback($value, $key)){
                    return $value;
                }
            }
        }
        else{
            return empty($values) ? null : $values[0];
        }
        return null;
    }
1311185
private function _last(callable $callback = null)
    {
        $values = $this->getValues();
        if ($callback){
            foreach(array_reverse($values) as $key => $value){
                if ($callback($value, $key)){
                    return $value;
                }
            }
        }
        else{
            return empty($values) ? null : $values[count($values)-1];
        }
        return null;
    }
327198
public function get($callback = null)
    {
        $result = $this->acquire();

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

        return $result;
    }
1189696
public function map(callable $callback)
    {
        $result = array();

        foreach ($this->nodes as $index => $node) {
            $return_value = \call_user_func($callback, $node, $index);

            if ($return_value === null) {
                continue;
            } elseif (\is_array($return_value)) {
                $result = \array_merge($result, $return_value);
            } else {
                $result[] = $return_value;
            }
        }

        return $result;
    }
1144696
public function map(callable $callback): CollectionInterface
    {
        $collection = clone $this;
        \array_map($callback, $collection->data);

        return $collection;
    }
1013057
public function eachSpread(callable $callback)
    {
        return $this->each(function ($chunk, $key) use ($callback) {
            $chunk[] = $key;

            return $callback(...$chunk);
        });
    }
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);
  }
1315054
public function getSumCallback($callback)
    {
        $callback = $this->getCallback($callback);

        // return array_sum(array_map($callback, $this->edges));

        $sum = 0;
        foreach ($this->edges as $edge) {
            $sum += $callback($edge);
        }
        return $sum;
    }
1036459
public function each(callable $callback)
    {
        foreach ($this->all() as $key => $value) {
            $callback($key, $value);
        }

        return $this;
    }
346606
protected function getCallback($callback)
	{
		if ( ! is_null($callback)) return $callback;

		$me = $this;

		return function($line) use ($me) { $me->display($line); };
	}
549479
public function resolve(callable $callback = null)
    {
        $active = null;
        $mh = $this->getMainHandle();

        do {
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc === CURLM_CALL_MULTI_PERFORM);

        while ($active && $mrc === CURLM_OK) {
            if (curl_multi_select($mh) === -1) {
                usleep(100);
            }

            do {
                $mrc = curl_multi_exec($mh, $active);
            } while ($mrc === CURLM_CALL_MULTI_PERFORM);
        }

        if ($mrc !== CURLM_OK) {
            throw new \RuntimeException("Curl multi read error $mrc\n", E_USER_WARNING);
        }

        /** @var CurlTransport $transport */
        $responses = [];
        $errors = [];
        $transport = $this->getTransport();

        foreach ($this->tasks as $task) {
            /** @var Promise $promise */
            $handle = $task['handle'];
            $promise = $task['promise'];

            $error = curl_error($handle);

            if (!$error) {
                $responses[] = $res = $transport->getResponse(curl_multi_getcontent($handle), curl_getinfo($handle));
                $promise->resolve($res);
            } else {
                $errors[] = $e = new \RuntimeException($error, curl_errno($handle));
                $promise->reject($e);
            }
        }

        $this->errors = $errors;

        if ($callback) {
            $callback($responses, $errors, $this);
        }

        $this->reset();

        return $responses;
    }
261124
public function find($callback)
    {
        foreach ($this->value as $value) {
            if (call_user_func($callback, $value)) {
                return $value;
            }
        }
        
        return null;
    }
119265
public function indexBy($callback)
    {
        $keys = array_map($callback, $this->value);
        $value = array_combine($keys, $this->value);
        return $this->setValue($value);
    }
524344
public function sort(callable $callback = null)
    {
        $items = $this->getArrayCopy();
        $callback ? uasort($items, $callback) : asort($items);
        return new static($items);
    }
1318825
public function filter(\Closure $callback)
    {
        $collection = new static();

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

        return $collection;
    }
148530
public function getJoinColumn(callable $callback = null)
    {
        $joinColumn = reset($this->joinColumns);

        if (is_callable($callback)) {
            $callback($joinColumn);
        }

        return $joinColumn;
    }
280754
public function collect(callable $callback)
    {
        $queue = new ComponentHolder();
        $queue->setBranches($this->branches);

        foreach ($this->getExtensions() as $extension) {
            call_user_func($callback, $extension, $queue);
        }

        return $queue;
    }