StandardDocumentationReader   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 8
eloc 12
c 2
b 0
f 0
dl 0
loc 28
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B get() 0 26 8
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 79
    public function get(DOMElement $node): string
12
    {
13 79
        $doc = '';
14
15
        /**
16
         * @var \DOMNode $childNode
17
         */
18 79
        foreach ($node->childNodes as $childNode) {
19 79
            if ($childNode instanceof DOMElement && $childNode->localName == 'annotation') {
20
                /**
21
                 * @var \DOMNode $subChildNode
22
                 */
23 79
                foreach ($childNode->childNodes as $subChildNode) {
24 79
                    if ($subChildNode instanceof DOMElement && $subChildNode->localName == 'documentation') {
25 78
                        if (!empty($doc)) {
26 74
                            $doc .= "\n".($subChildNode->nodeValue);
27
                        } else {
28 79
                            $doc .= ($subChildNode->nodeValue);
29
                        }
30
                    }
31
                }
32
            }
33
        }
34 79
        $doc = preg_replace('/[\t ]+/', ' ', $doc);
35
36 79
        return trim($doc);
37
    }
38
}
39