NodeTrait   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
eloc 8
c 2
b 0
f 0
dl 0
loc 31
ccs 8
cts 10
cp 0.8
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A collection() 0 2 1
A result() 0 6 2
A document() 0 6 2
1
<?php declare(strict_types=1);
2
3
namespace DOMWrap\Traits;
4
5
use DOMWrap\NodeList;
6
7
/**
8
 * Node Trait
9
 *
10
 * @package DOMWrap\Traits
11
 * @license http://opensource.org/licenses/BSD-3-Clause BSD 3 Clause
12
 * @property \DOMDocument $ownerDocument
13
 */
14
trait NodeTrait
15
{
16
    /**
17
     * @return NodeList
18
     */
19 85
    public function collection(): NodeList {
20 85
        return $this->newNodeList([$this]);
0 ignored issues
show
Bug introduced by
It seems like newNodeList() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
        return $this->/** @scrutinizer ignore-call */ newNodeList([$this]);
Loading history...
21
    }
22
23
    /**
24
     * @return \DOMDocument
25
     */
26 88
    public function document(): ?\DOMDocument {
27 88
        if ($this->isRemoved()) {
0 ignored issues
show
Bug introduced by
It seems like isRemoved() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
        if ($this->/** @scrutinizer ignore-call */ isRemoved()) {
Loading history...
28
            return null;
29
        }
30
31 88
        return $this->ownerDocument;
32
    }
33
34
    /**
35
     * @param NodeList $nodeList
36
     *
37
     * @return NodeList|\DOMNode|null
38
     */
39 52
    public function result(NodeList $nodeList) {
40 52
        if ($nodeList->count()) {
41 52
            return $nodeList->first();
42
        }
43
44
        return null;
45
    }
46
}