Passed
Pull Request — master (#18)
by SignpostMarv
05:20
created

StandardDocumentationReader::get()   C

Complexity

Conditions 7
Paths 5

Size

Total Lines 22
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 7

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 11
cts 11
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
namespace GoetasWebservices\XML\XSDReader\Documentation;
4
5
use DOMElement;
6
7
class StandardDocumentationReader implements DocumentationReader
8
{
9 52
    /**
10
    * @return string
11 52
    */
12 52
    public function get(DOMElement $node)
13 52
    {
14 52
        $doc = '';
15 52
16 51
        /**
17 51
        * @var \DOMNode $childNode
18 52
        */
19 52
        foreach ($node->childNodes as $childNode) {
20 52
            if ($childNode instanceof DOMElement && $childNode->localName == 'annotation') {
21 52
                /**
22
                * @var \DOMNode $subChildNode
23 52
                */
24
                foreach ($childNode->childNodes as $subChildNode) {
25
                    if ($subChildNode instanceof DOMElement && $subChildNode->localName == 'documentation') {
26
                        $doc .= ($subChildNode->nodeValue);
27
                    }
28
                }
29
            }
30
        }
31
        $doc = preg_replace('/[\t ]+/', ' ', $doc);
32
33
        return trim($doc);
34
    }
35
}
36