StandardDocumentationReader::get()   C
last analyzed

Complexity

Conditions 7
Paths 5

Size

Total Lines 22
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 7

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 9
cts 9
cp 1
rs 6.9811
c 0
b 0
f 0
cc 7
eloc 8
nc 5
nop 1
crap 7
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GoetasWebservices\XML\XSDReader\Documentation;
6
7
use DOMElement;
8
9
class StandardDocumentationReader implements DocumentationReader
10
{
11 63
    public function get(DOMElement $node): string
12
    {
13 63
        $doc = '';
14
15
        /**
16
         * @var \DOMNode $childNode
17
         */
18 63
        foreach ($node->childNodes as $childNode) {
19 63
            if ($childNode instanceof DOMElement && $childNode->localName == 'annotation') {
20
                /**
21
                 * @var \DOMNode $subChildNode
22
                 */
23 63
                foreach ($childNode->childNodes as $subChildNode) {
24 63
                    if ($subChildNode instanceof DOMElement && $subChildNode->localName == 'documentation') {
25 63
                        $doc .= ($subChildNode->nodeValue);
26
                    }
27
                }
28
            }
29
        }
30 63
        $doc = preg_replace('/[\t ]+/', ' ', $doc);
31
32 63
        return trim($doc);
33
    }
34
}
35