File indexing completed on 2024-05-12 06:02:46

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Markup
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  * @version    $Id$
0020  */
0021 
0022 /**
0023  * @see Zend_Markup_Token
0024  */
0025 // require_once 'Zend/Markup/Token.php';
0026 
0027 /**
0028  * @category   Zend
0029  * @package    Zend_Markup
0030  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0031  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0032  */
0033 class Zend_Markup_TokenList implements RecursiveIterator
0034 {
0035 
0036     /**
0037      * Array of tokens
0038      *
0039      * @var array
0040      */
0041     protected $_tokens = array();
0042 
0043     /**
0044      * Get the current token
0045      *
0046      * @return Zend_Markup_Token
0047      */
0048     public function current()
0049     {
0050         return current($this->_tokens);
0051     }
0052 
0053     /**
0054      * Get the children of the current token
0055      *
0056      * @return Zend_Markup_TokenList
0057      */
0058     public function getChildren()
0059     {
0060         return current($this->_tokens)->getChildren();
0061     }
0062 
0063     /**
0064      * Add a new child token
0065      *
0066      * @param Zend_Markup_Token $child
0067      *
0068      * @return void
0069      */
0070     public function addChild(Zend_Markup_Token $child)
0071     {
0072         $this->_tokens[] = $child;
0073     }
0074 
0075     /**
0076      * Check if the current token has children
0077      *
0078      * @return bool
0079      */
0080     public function hasChildren()
0081     {
0082         return current($this->_tokens)->hasChildren();
0083     }
0084 
0085     /**
0086      * Get the key of the current token
0087      *
0088      * @return int
0089      */
0090     public function key()
0091     {
0092         return key($this->_tokens);
0093     }
0094 
0095     /**
0096      * Go to the next token
0097      *
0098      * @return Zend_Markup_Token
0099      */
0100     public function next()
0101     {
0102         return next($this->_tokens);
0103     }
0104 
0105     /**
0106      * Rewind the iterator
0107      *
0108      * @return void
0109      */
0110     public function rewind()
0111     {
0112         reset($this->_tokens);
0113     }
0114 
0115     /**
0116      * Check if the element is valid
0117      *
0118      * @return void
0119      */
0120     public function valid()
0121     {
0122         return $this->current() !== false;
0123     }
0124 }