Passed
Push — spaghetti ( 4802b3...dd673c )
by simpletoimplement
02:07
created

Worksheet::getWorksheetPaths()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 9
nc 3
nop 1
dl 0
loc 16
rs 9.9666
c 0
b 0
f 0
1
<?php declare(strict_types = 1);
2
3
namespace Spaghetti\XLSXParser;
4
5
use XMLReader;
6
7
/**
8
 * @internal
9
 */
10
final class Worksheet extends AbstractXMLResource
11
{
12
    public function getWorksheetPaths(Relationships $relationships): array
13
    {
14
        $xml = $this->getXMLReader();
15
        $paths = [];
16
17
        while ($xml->read()) {
18
            if (XMLReader::ELEMENT === $xml->nodeType && 'sheet' === $xml->name) {
19
                $rId = $xml->getAttributeNs(
20
                    name: 'id',
21
                    namespace: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
22
                );
23
                $paths[$xml->getAttribute(name: 'name')] = $relationships->getWorksheetPath(rId: $rId);
24
            }
25
        }
26
27
        return $paths;
28
    }
29
}
30