DomElement::find()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rs\XmlFilter\Document;
6
7
class DomElement extends \DOMElement implements Element
8
{
9 1
    public function find(string $path) : array
10
    {
11 1
        $xpath = new \DOMXpath($this->ownerDocument);
12
13 1
        $nodes = $xpath->query($path, $this);
14
15 1
        $result = [];
16
17 1
        foreach ($nodes as $node) {
18 1
            $result[] = $node;
19
        }
20
21 1
        return $result;
22
    }
23
24 1
    public function __toString()
25
    {
26 1
        return (string) $this->textContent;
27
    }
28
29 1
    public function attribute($name) : string
30
    {
31 1
        return $this->getAttribute($name);
32
    }
33
}
34