Prado\Collections\TStack::pop PHP Method

pop() public method

Pops up the item at the top of the stack.
public pop ( ) : mixed
return mixed the item at the top of the stack
    public function pop()
    {
        if ($this->_c === 0) {
            throw new TInvalidOperationException('stack_empty');
        } else {
            --$this->_c;
            return array_pop($this->_d);
        }
    }

Usage Example

Ejemplo n.º 1
0
 public function testCanNotPopAnEmptyStack()
 {
     $stack = new TStack();
     try {
         $item = $stack->pop();
     } catch (TInvalidOperationException $e) {
         return;
     }
     self::fail('An expected TInvalidOperationException was not raised');
 }