@@ 13-22 (lines=10) @@ | ||
10 | ||
11 | class DomHelper |
|
12 | { |
|
13 | public function loadDocument(string $pathToXml): DOMDocument |
|
14 | { |
|
15 | if (!file_exists($pathToXml)) { |
|
16 | throw new RuntimeException(sprintf('File %s does not exist', $pathToXml)); |
|
17 | } |
|
18 | ||
19 | $document = $this->createEmptyDomDocument(); |
|
20 | $this->loadXmlContents($document, $pathToXml); |
|
21 | return $document; |
|
22 | } |
|
23 | ||
24 | public function loadOrCreateDocument(string $pathToXml): DOMDocument |
|
25 | { |
|
@@ 24-35 (lines=12) @@ | ||
21 | return $document; |
|
22 | } |
|
23 | ||
24 | public function loadOrCreateDocument(string $pathToXml): DOMDocument |
|
25 | { |
|
26 | $document = $this->createEmptyDomDocument(); |
|
27 | ||
28 | if (!file_exists($pathToXml)) { |
|
29 | return $document; |
|
30 | } |
|
31 | ||
32 | $this->loadXmlContents($document, $pathToXml); |
|
33 | ||
34 | return $document; |
|
35 | } |
|
36 | ||
37 | private function createEmptyDomDocument(): DOMDocument |
|
38 | { |