SPL-StandardPHPLibrary
Public Member Functions | Protected Member Functions | List of all members
IniGroups Class Reference
Inheritance diagram for IniGroups:
Inheritance graph
Collaboration diagram for IniGroups:
Collaboration graph

Public Member Functions

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

Protected Member Functions

 __clone ()
 
 fetch ()
 

Detailed Description

Class to iterate all groups within an ini file.

Author
Marcus Boerger
Version
1.1

Using this class you can iterator over all groups of a ini file.

This class uses a 'is-a' relation to KeyFilter in contrast to a 'has-a' relation. Doing so both current() and key() methods must be overwritten. If it would use a 'has-a' relation there would be much more to type... but for puritists that would allow correctness in so far as then no key() would be needed.

Definition at line 28 of file inigroups.inc.

Constructor & Destructor Documentation

IniGroups::__construct (   $file)

Construct an ini file group iterator from a filename.

Parameters
fileIni file to open.

Definition at line 35 of file inigroups.inc.

35  {
36  parent::__construct(new DbaReader($file, 'inifile'), '^\[.*\]$');
37  }
This implements a DBA Iterator.
Definition: dbareader.inc:17

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

Definition at line 121 of file filteriterator.inc.

122  {
123  return call_user_func_array(array($this->it, $func), $params);
124  }
KeyFilter::__clone ( )
protectedinherited

hidden __clone

Definition at line 58 of file keyfilter.inc.

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

Definition at line 43 of file keyfilter.inc.

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

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

Here is the call graph for this function:

IniGroups::current ( )
Returns
The current group.

Implements Iterator.

Definition at line 42 of file inigroups.inc.

42  {
43  return substr(parent::key(),1,-1);
44  }
FilterIterator::fetch ( )
protectedinherited

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().

61  {
62  while ($this->it->valid()) {
63  if ($this->accept()) {
64  return;
65  }
66  $this->it->next();
67  };
68  }
accept()
Accept function to decide whether an element of the inner iterator should be accessible through the F...

Here is the call graph for this function:

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

Definition at line 50 of file keyfilter.inc.

References KeyFilter\$regex.

51  {
52  return $this->regex;
53  }
IniGroups::key ( )
Returns
The current group.

Implements Iterator.

Definition at line 49 of file inigroups.inc.

49  {
50  return substr(parent::key(),1,-1);
51  }
FilterIterator::next ( )
inherited

Move to next element.

Returns
void

Implements Iterator.

Definition at line 75 of file filteriterator.inc.

References FilterIterator\fetch().

75  {
76  $this->it->next();
77  $this->fetch();
78  }
fetch()
Fetch next element and store it.

Here is the call graph for this function:

FilterIterator::rewind ( )
inherited

Rewind the inner iterator.

Implements Iterator.

Definition at line 42 of file filteriterator.inc.

References FilterIterator\fetch().

42  {
43  $this->it->rewind();
44  $this->fetch();
45  }
fetch()
Fetch next element and store it.

Here is the call graph for this function:

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

Implements Iterator.

Definition at line 83 of file filteriterator.inc.

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

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