FilesystemIterator::current()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
ccs 3
cts 3
cp 1
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Mattbit\Flat\Storage;
4
5
use Mattbit\Flat\Model\Document;
6
use Mattbit\Flat\Storage\EncoderInterface;
7
8
class FilesystemIterator implements \Iterator {
9
10
    /**
11
     * @var EncoderInterface
12
     */
13
    protected $encoder;
14
15
    /**
16
     * @var \Iterator
17
     */
18
    protected $iterator;
19
20 5
    public function __construct(EncoderInterface $encoder, $path)
21
    {
22 5
        $this->encoder = $encoder;
23 5
        $this->iterator = new \GlobIterator($path, \FilesystemIterator::CURRENT_AS_PATHNAME);
24 5
    }
25
26 1
    public function current()
27
    {
28 1
        $data = file_get_contents($this->iterator->current());
29
30 1
        return $this->encoder->decode($data);
31
    }
32
33 1
    public function key()
34
    {
35 1
        return $this->iterator->key();
36
    }
37
38 1
    public function next()
39
    {
40 1
    return $this->iterator->next();
41
    }
42
43 1
    public function rewind()
44
    {
45 1
        return $this->iterator->rewind();
46
    }
47
48 1
    public function valid()
49
    {
50 1
        return $this->iterator->valid();
51
    }
52
53 5
    public function setIterator(\Iterator $iterator)
54
    {
55 5
        $this->iterator = $iterator;
56 5
    }
57
}
58