Prado\Collections\TStack::peek PHP Метод

peek() публичный Метод

Unlike {@link pop()}, this method does not remove the item from the stack.
public peek ( ) : mixed
Результат mixed item at the top of the stack
    public function peek()
    {
        if ($this->_c === 0) {
            throw new TInvalidOperationException('stack_empty');
        } else {
            return $this->_d[$this->_c - 1];
        }
    }

Usage Example

Пример #1
0
 public function testCanNotPeekAnEmptyStack()
 {
     $stack = new TStack();
     try {
         $item = $stack->peek();
     } catch (TInvalidOperationException $e) {
         return;
     }
     self::fail('An expected TInvalidOperationException was not raised');
 }