DumpIterator::key()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Queryr\DumpReader;
4
5
use Iterator;
6
7
/**
8
 * @licence GNU GPL v2+
9
 * @author Jeroen De Dauw < [email protected] >
10
 */
11
class DumpIterator implements Iterator {
12
13
	/**
14
	 * @var DumpReader
15
	 */
16
	private $reader;
17
18
	/**
19
	 * @var Page|null
20
	 */
21
	private $current;
22
23
	/**
24
	 * @var int
25
	 */
26
	private $key = 0;
27
28
	public function __construct( DumpReader $reader ) {
29
		$this->reader = $reader;
30
	}
31
32
	/**
33
	 * @return Page|null
34
	 */
35
	public function current() {
36
		return $this->current;
37
	}
38
39
	public function next() {
40
		$this->current = $this->reader->nextEntityPage();
41
		$this->key++;
42
	}
43
44
	/**
45
	 * @return int
46
	 */
47
	public function key() {
48
		return $this->key;
49
	}
50
51
	/**
52
	 * @return bool
53
	 */
54
	public function valid() {
55
		return $this->current !== null;
56
	}
57
58
	public function rewind() {
59
		$this->key = 0;
60
		$this->next();
61
	}
62
63
}
64