/
Iterator.php
64 lines (52 loc) · 1018 Bytes
/
Iterator.php
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
<?php
namespace Util;
abstract class Iterator extends \Kinesis\Object implements \Iterator
{
protected $position = 0;
public $Data = array();
function valid()
{
return false;
}
function current()
{
return null;
}
function key()
{
return $this->position;
}
function next()
{
$this->increment();
}
function rewind()
{
$this->position = 0;
}
function clear()
{
$this->rewind();
}
protected function increment()
{
return $this->shift( 1 );
}
protected function decrement()
{
return $this->shift( -1 );
}
protected function position( $position = null )
{
if( is_int( $position ))
{
$this->position = $position;
return $this;
}
return $this->position;
}
protected function shift( $amount )
{
return $this->position( $this->position + $amount );
}
}