/** * Get the first item from the collection. * * @param callable|null $callback * @param mixed $default * @return mixed */ public function first(callable $callback = null, $default = null) { if (is_null($callback)) { return count($this->items) > 0 ? reset($this->items) : value($default); } return Arr::first($this->items, $callback, $default); }
/** * Return the first element in an array passing a given truth test. * * @param array $array * @param callable $callback * @param mixed $default * @return mixed */ function array_first($array, callable $callback, $default = null) { return Arr::first($array, $callback, $default); }