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

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

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

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

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

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

@return mixed Last appended item

@throws UnderflowException
Return the last element of the collection