39d02aacac19c9654cc89fab28d7a8fca0de8f53
[yaffs-website] / vendor / zendframework / zend-stdlib / src / ArrayStack.php
1 <?php
2 /**
3  * Zend Framework (http://framework.zend.com/)
4  *
5  * @link      http://github.com/zendframework/zf2 for the canonical source repository
6  * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7  * @license   http://framework.zend.com/license/new-bsd New BSD License
8  */
9
10 namespace Zend\Stdlib;
11
12 use ArrayIterator;
13 use ArrayObject as PhpArrayObject;
14
15 /**
16  * ArrayObject that acts as a stack with regards to iteration
17  */
18 class ArrayStack extends PhpArrayObject
19 {
20     /**
21      * Retrieve iterator
22      *
23      * Retrieve an array copy of the object, reverse its order, and return an
24      * ArrayIterator with that reversed array.
25      *
26      * @return ArrayIterator
27      */
28     public function getIterator()
29     {
30         $array = $this->getArrayCopy();
31         return new ArrayIterator(array_reverse($array));
32     }
33 }