src/Collection.php
public function first(callable $filter = null, array $args = [], $default = null)
    {
        // Use $this if no filter provided
        $filtered = ($filter === null)
            ? $this
            : $this->filter($filter, $args)
        ;

        // Return first value or default if filtered collection is empty
        return empty($filtered) ? $default : reset($filtered);
    }
public function first(callable $filter = null, array $args = [], $default = null)
    {
        // Use $this if no filter provided
        $filtered = ($filter === null)
            ? $this
            : $this->filter($filter, $args)
        ;

        // Return first value or default if filtered collection is empty
        return empty($filtered) ? $default : reset($filtered);
    }
public function first ( callable $ filter = null , array $ args = [ ] , $ default = null ) { // Use $this if no filter provided $ filtered = ( $ filter === null ) ? $ this : $ this -> filter ( $ filter , $ args ) ; // Return first value or default if filtered collection is empty return empty ( $ filtered ) ? $ default : reset ( $ filtered ) ; }
Return first element matching criteria

@param callable|null $filter - user-defined function to filter elements
@param array $args - OPTIONAL array of arguments to pass to the callable
@param mixed|null $default - OPTIONAL default value to return
@return mixed
Return first element matching criteria