SimpleXmlElement   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 24
ccs 9
cts 10
cp 0.9
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A find() 0 10 2
A attribute() 0 10 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rs\XmlFilter\Document;
6
7
use Rs\XmlFilter\Exception\EvaluationException;
8
9
class SimpleXmlElement extends \SimpleXMLElement implements Element
10
{
11 37
    public function find(string $path) : array
12
    {
13 37
        $result = $this->xpath($path);
14
15 37
        if (false === $result) {
16
            throw new EvaluationException(sprintf('unable to evaluate the "%s"', $path), $this, ['path' => $path]);
17
        }
18
19 37
        return $result;
20
    }
21
22 1
    public function attribute($name) : string
23
    {
24 1
        foreach ($this->attributes() as $key => $value) {
25 1
            if ($key === $name) {
26 1
                return (string) $value;
27
            }
28
        }
29
30 1
        return '';
31
    }
32
}
33