1 | <?php |
||
17 | class SheetIterator implements IteratorInterface |
||
18 | { |
||
19 | const CONTENT_XML_FILE_PATH = 'content.xml'; |
||
20 | |||
21 | /** Definition of XML nodes name and attribute used to parse sheet data */ |
||
22 | const XML_NODE_TABLE = 'table:table'; |
||
23 | const XML_ATTRIBUTE_TABLE_NAME = 'table:name'; |
||
24 | |||
25 | /** @var string $filePath Path of the file to be read */ |
||
26 | protected $filePath; |
||
27 | |||
28 | /** @var \Box\Spout\Reader\ODS\ReaderOptions Reader's current options */ |
||
29 | protected $options; |
||
30 | |||
31 | /** @var XMLReader The XMLReader object that will help read sheet's XML data */ |
||
32 | protected $xmlReader; |
||
33 | |||
34 | /** @var \Box\Spout\Common\Escaper\ODS Used to unescape XML data */ |
||
35 | protected $escaper; |
||
36 | |||
37 | /** @var bool Whether there are still at least a sheet to be read */ |
||
38 | protected $hasFoundSheet; |
||
39 | |||
40 | /** @var int The index of the sheet being read (zero-based) */ |
||
41 | protected $currentSheetIndex; |
||
42 | |||
43 | /** @var string The name of the sheet that was defined as active */ |
||
44 | protected $activeSheetName; |
||
45 | |||
46 | /** |
||
47 | * @param string $filePath Path of the file to be read |
||
48 | * @param \Box\Spout\Reader\ODS\ReaderOptions $options Reader's current options |
||
49 | * @throws \Box\Spout\Reader\Exception\NoSheetsFoundException If there are no sheets in the file |
||
50 | */ |
||
51 | 90 | public function __construct($filePath, $options) |
|
63 | |||
64 | /** |
||
65 | * Rewind the Iterator to the first element |
||
66 | * @link http://php.net/manual/en/iterator.rewind.php |
||
67 | * |
||
68 | * @return void |
||
69 | * @throws \Box\Spout\Common\Exception\IOException If unable to open the XML file containing sheets' data |
||
70 | */ |
||
71 | 90 | public function rewind() |
|
88 | |||
89 | /** |
||
90 | * Checks if current position is valid |
||
91 | * @link http://php.net/manual/en/iterator.valid.php |
||
92 | * |
||
93 | * @return bool |
||
94 | */ |
||
95 | 84 | public function valid() |
|
99 | |||
100 | /** |
||
101 | * Move forward to next element |
||
102 | * @link http://php.net/manual/en/iterator.next.php |
||
103 | * |
||
104 | * @return void |
||
105 | */ |
||
106 | 81 | public function next() |
|
114 | |||
115 | /** |
||
116 | * Return the current element |
||
117 | * @link http://php.net/manual/en/iterator.current.php |
||
118 | * |
||
119 | * @return \Box\Spout\Reader\ODS\Sheet |
||
120 | */ |
||
121 | 84 | public function current() |
|
129 | |||
130 | /** |
||
131 | * Returns whether the current sheet was defined as the active one |
||
132 | * |
||
133 | * @param string $sheetName Name of the current sheet |
||
134 | * @param int $sheetIndex Index of the current sheet |
||
135 | * @param string|null Name of the sheet that was defined as active or NULL if none defined |
||
136 | * @return bool Whether the current sheet was defined as the active one |
||
137 | */ |
||
138 | 84 | private function isActiveSheet($sheetName, $sheetIndex, $activeSheetName) |
|
147 | |||
148 | /** |
||
149 | * Return the key of the current element |
||
150 | * @link http://php.net/manual/en/iterator.key.php |
||
151 | * |
||
152 | * @return int |
||
153 | */ |
||
154 | 72 | public function key() |
|
158 | |||
159 | /** |
||
160 | * Cleans up what was created to iterate over the object. |
||
161 | * |
||
162 | * @return void |
||
163 | */ |
||
164 | 81 | public function end() |
|
168 | } |
||
169 |