mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 22:04:25 +02:00
Implement abstract class EnumeratingFilterIterator
This commit is contained in:
parent
ee63dfd310
commit
081d8eecfc
37
library/Icinga/Util/EnumeratingFilterIterator.php
Normal file
37
library/Icinga/Util/EnumeratingFilterIterator.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Icinga\Util;
|
||||||
|
|
||||||
|
use FilterIterator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class EnumeratingFilterIterator
|
||||||
|
*
|
||||||
|
* FilterIterator with continuous numeric key (index)
|
||||||
|
*/
|
||||||
|
abstract class EnumeratingFilterIterator extends FilterIterator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $index;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function rewind()
|
||||||
|
{
|
||||||
|
parent::rewind();
|
||||||
|
$this->index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function key()
|
||||||
|
{
|
||||||
|
return $this->index++;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user