SharedStrings::readNext()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.2888
c 0
b 0
f 0
cc 5
nc 5
nop 0
1
<?php
2
3
namespace Akeneo\Component\SpreadsheetParser\Xlsx;
4
5
/**
6
 * Contains the shared strings of an Excel spreadsheet
7
 *
8
 * @author    Antoine Guigan <[email protected]>
9
 * @copyright 2014 Akeneo SAS (http://www.akeneo.com)
10
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
11
 */
12
class SharedStrings extends AbstractXMLDictionnary
13
{
14
    /**
15
     * @var int
16
     */
17
    protected $currentIndex = -1;
18
19
    /**
20
     * Reads the next value in the file
21
     */
22
    protected function readNext()
23
    {
24
        $xml = $this->getXMLReader();
25
        while ($xml->read()) {
26
            if (\XMLReader::ELEMENT === $xml->nodeType) {
27
                switch ($xml->name) {
28
                    case 'si':
29
                        $this->currentIndex++;
30
                        break;
31
                    case 't':
32
                        $this->values[$this->currentIndex] = $xml->readString();
33
34
                        return;
35
                }
36
            }
37
        }
38
39
        $this->valid = false;
40
        $this->closeXMLReader();
41
    }
42
}
43