| @@ 17-30 (lines=14) @@ | ||
| 14 | $this->domXpath = new \DOMXPath($doc); |
|
| 15 | } |
|
| 16 | ||
| 17 | public static function fromFile(string $filePath) : Reader |
|
| 18 | { |
|
| 19 | $doc = new \DOMDocument(); |
|
| 20 | ||
| 21 | try { |
|
| 22 | if (false === file_exists($filePath) || false === $doc->load($filePath)) { |
|
| 23 | throw new \RuntimeException(sprintf('Could not load xml file [%s].', $filePath)); |
|
| 24 | } |
|
| 25 | } catch (\Exception $e) { |
|
| 26 | throw new \RuntimeException($e->getMessage()); |
|
| 27 | } |
|
| 28 | ||
| 29 | return new self($doc); |
|
| 30 | } |
|
| 31 | ||
| 32 | public static function fromString(string $xmlStr) : Reader |
|
| 33 | { |
|
| @@ 32-45 (lines=14) @@ | ||
| 29 | return new self($doc); |
|
| 30 | } |
|
| 31 | ||
| 32 | public static function fromString(string $xmlStr) : Reader |
|
| 33 | { |
|
| 34 | $doc = new \DOMDocument(); |
|
| 35 | ||
| 36 | try { |
|
| 37 | if (false === $doc->loadXML($xmlStr)) { |
|
| 38 | throw new \RuntimeException(sprintf('Could not load XML from string [%s]', $xmlStr)); |
|
| 39 | } |
|
| 40 | } catch (\Exception $e) { |
|
| 41 | throw new \RuntimeException($e->getMessage()); |
|
| 42 | } |
|
| 43 | ||
| 44 | return new self($doc); |
|
| 45 | } |
|
| 46 | ||
| 47 | public function getList(string $xpath) : array |
|
| 48 | { |
|