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
10namespace Zend\Stdlib;
11
12use ArrayIterator;
13use ArrayObject as PhpArrayObject;
14
15/**
16 * ArrayObject that acts as a stack with regards to iteration
17 */
18class 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}
34