| Total Complexity | 7 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types = 1); |
||
| 12 | final class Relationships extends AbstractXMLResource |
||
| 13 | { |
||
| 14 | private array $workSheetPaths = []; |
||
| 15 | private string $sharedStringPath = ''; |
||
| 16 | private string $stylePath = ''; |
||
| 17 | |||
| 18 | public function __construct(string $path) |
||
| 19 | { |
||
| 20 | parent::__construct(path: $path); |
||
| 21 | $xml = $this->getXMLReader(); |
||
| 22 | |||
| 23 | while ($xml->read()) { |
||
| 24 | if (XMLReader::ELEMENT === $xml->nodeType && 'Relationship' === $xml->name) { |
||
| 25 | $target = 'xl/' . $xml->getAttribute(name: 'Target'); |
||
| 26 | |||
| 27 | match (basename(path: (string) $xml->getAttribute(name: 'Type'))) { |
||
| 28 | 'worksheet' => $this->workSheetPaths[$xml->getAttribute(name: 'Id')] = $target, |
||
| 29 | 'styles' => $this->stylePath = $target, |
||
| 30 | 'sharedStrings' => $this->sharedStringPath = $target, |
||
| 31 | default => null, |
||
| 32 | }; |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | $this->closeXMLReader(); |
||
| 37 | } |
||
| 38 | |||
| 39 | public function getWorksheetPath(string $rId): string |
||
| 40 | { |
||
| 41 | return $this->workSheetPaths[$rId]; |
||
| 42 | } |
||
| 43 | |||
| 44 | public function getSharedStringsPath(): string |
||
| 47 | } |
||
| 48 | |||
| 49 | public function getStylesPath(): string |
||
| 52 | } |
||
| 53 | } |
||
| 54 |