public function first()
    {
        if ($this->count() == 0) {
            throw new UnderflowException('Unexpected empty state');
        }

        $values = $this->toArray();
        reset($values);
        $lastKey = key($values);

        return $this->get($lastKey);
    }
public function first()
    {
        if ($this->count() == 0) {
            throw new UnderflowException('Unexpected empty state');
        }

        $values = $this->toArray();
        reset($values);
        $lastKey = key($values);

        return $this->get($lastKey);
    }
public function first ( ) { if ( $ this -> count ( ) == 0 ) { throw new UnderflowException ( 'Unexpected empty state' ) ; } $ values = $ this -> toArray ( ) ; reset ( $ values ) ; $ lastKey = key ( $ values ) ; return $ this -> get ( $ lastKey ) ; }
Return the first element of the collection

The first element is the first having been added to the collection,
not necessarily the one with the lowest index (for numerical indices)

@return mixed

@throws UnderflowException
Return the first element of the collection