SPL-StandardPHPLibrary
Public Member Functions | Protected Member Functions | Private Attributes
KeyFilter Class Reference
Inheritance diagram for KeyFilter:
Inheritance graph
[legend]
Collaboration diagram for KeyFilter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 __call ($func, $params)
 __construct (Iterator $it, $regex)
 accept ()
 current ()
 getInnerIterator ()
 getRegex ()
 key ()
 next ()
 rewind ()
 valid ()

Protected Member Functions

 __clone ()
 fetch ()

Private Attributes

 $regex

Detailed Description

Regular expression filter for string iterators.

Author:
Marcus Boerger
Version:
1.1

Instances of this class act as a filter around iterators whose elements are strings. In other words you can put an iterator into the constructor and the instance will only return elements which match the given regular expression.

Definition at line 22 of file keyfilter.inc.


Constructor & Destructor Documentation

KeyFilter::__construct ( Iterator it,
regex 
)

Constructs a filter around an iterator whose elemnts are strings.

If the given iterator is of type spl_sequence then its rewind() method is called.

Parameters:
itObject that implements at least spl_forward
regexRegular expression used as a filter.

Definition at line 35 of file keyfilter.inc.

References $regex.

    {
        parent::__construct($it);
        $this->regex = $regex;
    }

Member Function Documentation

FilterIterator::__call ( func,
params 
) [inherited]

Aggregate the inner iterator.

Parameters:
funcName of method to invoke
paramsArray of parameters to pass to method

Reimplemented in SearchIterator.

Definition at line 121 of file filteriterator.inc.

    {
        return call_user_func_array(array($this->it, $func), $params);
    }
KeyFilter::__clone ( ) [protected]

hidden __clone

Reimplemented from FilterIterator.

Definition at line 58 of file keyfilter.inc.

    {
        // disallow clone 
    }
KeyFilter::accept ( )
Returns:
whether the current key mathes the regular expression

Reimplemented from FilterIterator.

Definition at line 43 of file keyfilter.inc.

References FilterIterator\getInnerIterator(), and FilterIterator\key().

    {
        return ereg($this->regex, $this->getInnerIterator()->key());
    }

Here is the call graph for this function:

FilterIterator::current ( ) [inherited]
Returns:
The current value

Implements Iterator.

Reimplemented in RegexIterator, CallbackFilterIterator, and IniGroups.

Definition at line 97 of file filteriterator.inc.

Referenced by RegexFindFile\accept(), and FindFile\accept().

                       {
        return $this->it->current();
    }
FilterIterator::fetch ( ) [protected, inherited]

Fetch next element and store it.

Returns:
void

Definition at line 61 of file filteriterator.inc.

References FilterIterator\accept().

Referenced by FilterIterator\next(), and FilterIterator\rewind().

                               {
        while ($this->it->valid()) {
            if ($this->accept()) {
                return;
            }
            $this->it->next();
        };
    }

Here is the call graph for this function:

FilterIterator::getInnerIterator ( ) [inherited]
KeyFilter::getRegex ( )
Returns:
regular expression used as filter

Definition at line 50 of file keyfilter.inc.

    {
        return $this->regex;
    }
FilterIterator::key ( ) [inherited]
Returns:
The current key

Implements Iterator.

Reimplemented in RegexIterator, CallbackFilterIterator, IniGroups, and DirectoryFilterDots.

Definition at line 90 of file filteriterator.inc.

Referenced by accept().

                   {
        return $this->it->key();
    }
FilterIterator::next ( ) [inherited]

Move to next element.

Returns:
void

Implements Iterator.

Reimplemented in SearchIterator.

Definition at line 75 of file filteriterator.inc.

References FilterIterator\fetch().

                    {
        $this->it->next();
        $this->fetch();
    }

Here is the call graph for this function:

FilterIterator::rewind ( ) [inherited]

Rewind the inner iterator.

Implements Iterator.

Reimplemented in SearchIterator.

Definition at line 42 of file filteriterator.inc.

References FilterIterator\fetch().

                      { 
        $this->it->rewind();
        $this->fetch();
    }

Here is the call graph for this function:

FilterIterator::valid ( ) [inherited]
Returns:
Whether more elements are available

Implements Iterator.

Reimplemented in SearchIterator.

Definition at line 83 of file filteriterator.inc.

                     {
        return $this->it->valid();
    }

Member Data Documentation

KeyFilter::$regex [private]

regular exoression used as filter

Definition at line 25 of file keyfilter.inc.

Referenced by __construct().


The documentation for this class was generated from the following file: