ArrayNode   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 22
ccs 4
cts 4
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A count() 0 3 1
A getIterator() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PHPHtmlParser\Dom\Node;
6
7
use ArrayIterator;
8
use Countable;
9
use IteratorAggregate;
10
use PHPHtmlParser\Dom\Tag;
11
12
/**
13
 * Dom node object which will allow users to use it as
14
 * an array.
15
 *
16
 * @property-read string    $outerhtml
17
 * @property-read string    $innerhtml
18
 * @property-read string    $innerText
19
 * @property-read string    $text
20
 * @property-read Tag       $tag
21
 * @property-read InnerNode $parent
22
 */
23
abstract class ArrayNode extends AbstractNode implements IteratorAggregate, Countable
24
{
25
    /**
26
     * Gets the iterator.
27
     */
28 3
    public function getIterator(): ArrayIterator
29
    {
30 3
        return new ArrayIterator($this->getIteratorArray());
31
    }
32
33
    /**
34
     * Returns the count of the iterator array.
35
     */
36 3
    public function count(): int
37
    {
38 3
        return \count($this->getIteratorArray());
39
    }
40
41
    /**
42
     * Returns the array to be used the the iterator.
43
     */
44
    abstract protected function getIteratorArray(): array;
45
}
46