Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
namespace PhpOffice\PhpSpreadsheet\Worksheet;
4
 
5
use PhpOffice\PhpSpreadsheet\Spreadsheet;
6
 
7
/**
8
 * @implements \Iterator<int, Worksheet>
9
 */
10
class Iterator implements \Iterator
11
{
12
    /**
13
     * Spreadsheet to iterate.
14
     *
15
     * @var Spreadsheet
16
     */
17
    private $subject;
18
 
19
    /**
20
     * Current iterator position.
21
     *
22
     * @var int
23
     */
24
    private $position = 0;
25
 
26
    /**
27
     * Create a new worksheet iterator.
28
     */
29
    public function __construct(Spreadsheet $subject)
30
    {
31
        // Set subject
32
        $this->subject = $subject;
33
    }
34
 
35
    /**
36
     * Rewind iterator.
37
     */
38
    public function rewind(): void
39
    {
40
        $this->position = 0;
41
    }
42
 
43
    /**
44
     * Current Worksheet.
45
     */
46
    public function current(): Worksheet
47
    {
48
        return $this->subject->getSheet($this->position);
49
    }
50
 
51
    /**
52
     * Current key.
53
     */
54
    public function key(): int
55
    {
56
        return $this->position;
57
    }
58
 
59
    /**
60
     * Next value.
61
     */
62
    public function next(): void
63
    {
64
        ++$this->position;
65
    }
66
 
67
    /**
68
     * Are there more Worksheet instances available?
69
     */
70
    public function valid(): bool
71
    {
72
        return $this->position < $this->subject->getSheetCount() && $this->position >= 0;
73
    }
74
}