blob: 6a1d72c95885da5f9ff9579ec6d6faf005399d20 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<?php
/**
* Isis entry iterator. Iterates over all entries in
* the database.
*/
class IsisEntryIterator implements Iterator
{
private $start;
private $entry;
private $entries;
/**
* Constructor.
*
* @param $class
* Instance of IsisConnector or child class.
*
* @param $entry
* Start entry number to iterate from.
*/
public function __construct($class, $entry = 1) {
// Read the first value.
$class->read($entry);
// Setup.
$this->class = $class;
$this->entry = $this->start = $entry;
$this->entries = $class->entries;
}
/**
* Rewind the Iterator to the first element.
*/
function rewind() {
$this->entry = $this->start;
}
/**
* Return the key of the current element.
*/
function key() {
return $this->entry;
}
/**
* Return the current element.
*/
function current() {
return $this->class->result;
}
/**
* Move forward to next element.
*/
function next() {
$this->class->read(++$this->entry);
}
/**
* Check if there is a current element after calls to rewind() or next().
*/
function valid() {
return $this->entry <= $this->entries;
}
}
|