SheetIterator   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 81
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A rewind() 0 4 1
A valid() 0 4 1
A next() 0 4 1
A current() 0 4 1
A key() 0 4 1
A end() 0 4 1
A __construct() 0 4 1
1
<?php
2
3
namespace Box\Spout\Reader\CSV;
4
5
use Box\Spout\Reader\IteratorInterface;
6
7
/**
8
 * Class SheetIterator
9
 * Iterate over CSV unique "sheet".
10
 */
11
class SheetIterator implements IteratorInterface
12
{
13
    /** @var \Box\Spout\Reader\CSV\Sheet The CSV unique "sheet" */
14
    protected $sheet;
15
16
    /** @var bool Whether the unique "sheet" has already been read */
17
    protected $hasReadUniqueSheet = false;
18
19
    /**
20
     * @param Sheet $sheet Corresponding unique sheet
21
     */
22 27
    public function __construct($sheet)
23
    {
24 27
        $this->sheet = $sheet;
25 27
    }
26
27
    /**
28
     * Rewind the Iterator to the first element
29
     * @see http://php.net/manual/en/iterator.rewind.php
30
     *
31
     * @return void
32
     */
33 26
    public function rewind()
34
    {
35 26
        $this->hasReadUniqueSheet = false;
36 26
    }
37
38
    /**
39
     * Checks if current position is valid
40
     * @see http://php.net/manual/en/iterator.valid.php
41
     *
42
     * @return bool
43
     */
44 26
    public function valid()
45
    {
46 26
        return (!$this->hasReadUniqueSheet);
47
    }
48
49
    /**
50
     * Move forward to next element
51
     * @see http://php.net/manual/en/iterator.next.php
52
     *
53
     * @return void
54
     */
55 26
    public function next()
56
    {
57 26
        $this->hasReadUniqueSheet = true;
58 26
    }
59
60
    /**
61
     * Return the current element
62
     * @see http://php.net/manual/en/iterator.current.php
63
     *
64
     * @return \Box\Spout\Reader\CSV\Sheet
65
     */
66 27
    public function current()
67
    {
68 27
        return $this->sheet;
69
    }
70
71
    /**
72
     * Return the key of the current element
73
     * @see http://php.net/manual/en/iterator.key.php
74
     *
75
     * @return int
76
     */
77 20
    public function key()
78
    {
79 20
        return 1;
80
    }
81
82
    /**
83
     * Cleans up what was created to iterate over the object.
84
     *
85
     * @return void
86
     */
87 27
    public function end()
88
    {
89
        // do nothing
90 27
    }
91
}
92