Completed
Pull Request — master (#17)
by
unknown
01:37
created

AbstractExtractor::key()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Extraload\Extractor\Doctrine;
4
5
use Extraload\Extractor\ExtractorInterface;
6
7
abstract class AbstractExtractor implements ExtractorInterface
8
{
9
    protected $stmt;
10
11
    protected $position;
12
13
    protected $data;
14
15
    public function extract()
16
    {
17
        if (count($this->data) >= $this->stmt->rowCount()) {
18
            return;
19
        }
20
        $this->data[$this->position] = $this->stmt->fetch();
21
        $data = $this->current();
22
        $this->next();
23
24
        return $data;
25
    }
26
27
    public function current()
28
    {
29
        return $this->data[$this->position];
30
    }
31
32
    public function key()
33
    {
34
        return $this->position;
35
    }
36
37
    public function next()
38
    {
39
        $this->position += 1;
40
    }
41
42
    public function rewind()
43
    {
44
        $this->position = 0;
45
    }
46
47
    public function valid()
48
    {
49
        return isset($this->data[$this->position]);
50
    }
51
}
52