1<?php 2 3/** @file recursiveregexiterator.inc 4 * @ingroup SPL 5 * @brief class RegexIterator 6 * @author Marcus Boerger 7 * @date 2003 - 2009 8 * 9 * SPL - Standard PHP Library 10 */ 11 12/** 13 * @brief Recursive regular expression filter for iterators 14 * @author Marcus Boerger 15 * @version 1.0 16 * @since PHP 5.1 17 * 18 * This filter iterator assumes that the inner iterator 19 */ 20class RecursiveRegexIterator extends RegexIterator implements RecursiveIterator 21{ 22 /** 23 * Constructs a regular expression filter around an iterator whose 24 * elemnts or keys are strings. 25 * 26 * @param it inner iterator 27 * @param regex the regular expression to match 28 * @param mode operation mode (one of self::MATCH, self::GET_MATCH, 29 * self::ALL_MATCHES, self::SPLIT) 30 * @param flags special flags (self::USE_KEY) 31 * @param preg_flags global PREG_* flags, see preg_match(), 32 * preg_match_all(), preg_split() 33 */ 34 function __construct(RecursiveIterator $it, $regex, $mode = 0, $flags = 0, $preg_flags = 0) { 35 parent::__construct($it, $regex, $mode, $flags, $preg_flags); 36 } 37 38 /** @return whether the current element has children 39 */ 40 function hasChildren() 41 { 42 return $this->getInnerIterator()->hasChildren(); 43 } 44 45 /** @return an iterator for the current elements children 46 * 47 * @note the returned iterator will be of the same class as $this 48 */ 49 function getChildren() 50 { 51 if (empty($this->ref)) 52 { 53 $this->ref = new ReflectionClass($this); 54 } 55 return $this->ref->newInstance($this->getInnerIterator()->getChildren()); 56 } 57 58 private $ref; 59} 60 61?> 62