forked from goetas-webservices/xsd-reader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStandardDocumentationReader.php
More file actions
36 lines (31 loc) · 1.07 KB
/
StandardDocumentationReader.php
File metadata and controls
36 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
declare(strict_types=1);
namespace GoetasWebservices\XML\XSDReader\Documentation;
class StandardDocumentationReader implements DocumentationReader
{
public function get(\DOMElement $node): string
{
$doc = '';
/**
* @var \DOMNode $childNode
*/
foreach ($node->childNodes as $childNode) {
if ($childNode instanceof \DOMElement && 'annotation' === $childNode->localName) {
/**
* @var \DOMNode $subChildNode
*/
foreach ($childNode->childNodes as $subChildNode) {
if ($subChildNode instanceof \DOMElement && 'documentation' === $subChildNode->localName) {
if (!empty($doc)) {
$doc .= "\n" . $subChildNode->nodeValue;
} else {
$doc .= $subChildNode->nodeValue;
}
}
}
}
}
$doc = preg_replace('/[\t ]+/', ' ', $doc);
return trim($doc);
}
}