Overview

Packages

  • Support

Classes

  • Horde_Support_Array
  • Horde_Support_Backtrace
  • Horde_Support_CombineStream
  • Horde_Support_ConsistentHash
  • Horde_Support_Guid
  • Horde_Support_Inflector
  • Horde_Support_Memory
  • Horde_Support_Numerizer
  • Horde_Support_Numerizer_Locale_Base
  • Horde_Support_Numerizer_Locale_De
  • Horde_Support_Numerizer_Locale_Pt
  • Horde_Support_Randomid
  • Horde_Support_Stack
  • Horde_Support_StringStream
  • Horde_Support_Stub
  • Horde_Support_Timer
  • Horde_Support_Uuid
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Simple class for using an array as a stack.
 4:  *
 5:  * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
 6:  *
 7:  * @category   Horde
 8:  * @package    Support
 9:  * @license    http://www.horde.org/licenses/bsd
10:  */
11: class Horde_Support_Stack
12: {
13:     /**
14:      * @var array
15:      */
16:     protected $_stack = array();
17: 
18:     public function __construct($stack = array())
19:     {
20:         $this->_stack = $stack;
21:     }
22: 
23:     public function push($value)
24:     {
25:         $this->_stack[] = $value;
26:     }
27: 
28:     public function pop()
29:     {
30:         return array_pop($this->_stack);
31:     }
32: 
33:     public function peek($offset = 1)
34:     {
35:         if (isset($this->_stack[count($this->_stack) - $offset])) {
36:             return $this->_stack[count($this->_stack) - $offset];
37:         } else {
38:             return null;
39:         }
40:     }
41: }
42: 
API documentation generated by ApiGen