Box\Spout\Reader\XLSX\Helper\SharedStringsHelper::getSharedStringsUniqueCount PHP Method

getSharedStringsUniqueCount() protected method

Returns the shared strings unique count, as specified in tag.
protected getSharedStringsUniqueCount ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer | null
$xmlReader Box\Spout\Reader\Wrapper\XMLReader XMLReader instance
return integer | null Number of unique shared strings in the sharedStrings.xml file
    protected function getSharedStringsUniqueCount($xmlReader)
    {
        $xmlReader->next('sst');
        // Iterate over the "sst" elements to get the actual "sst ELEMENT" (skips any DOCTYPE)
        while ($xmlReader->name === 'sst' && $xmlReader->nodeType !== XMLReader::ELEMENT) {
            $xmlReader->read();
        }
        $uniqueCount = $xmlReader->getAttribute('uniqueCount');
        // some software do not add the "uniqueCount" attribute but only use the "count" one
        // @see https://github.com/box/spout/issues/254
        if ($uniqueCount === null) {
            $uniqueCount = $xmlReader->getAttribute('count');
        }
        return $uniqueCount !== null ? intval($uniqueCount) : null;
    }