Passed
Push — master ( 668c77...c11634 )
by Gilles
02:19
created

ArrayNode   A

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
11
/**
12
 * Dom node object which will allow users to use it as
13
 * an array.
14
 */
15
abstract class ArrayNode extends AbstractNode implements IteratorAggregate, Countable
16
{
17
    /**
18
     * Gets the iterator.
19
     */
20 3
    public function getIterator(): ArrayIterator
21
    {
22 3
        return new ArrayIterator($this->getIteratorArray());
23
    }
24
25
    /**
26
     * Returns the count of the iterator array.
27
     */
28 3
    public function count(): int
29
    {
30 3
        return \count($this->getIteratorArray());
31
    }
32
33
    /**
34
     * Returns the array to be used the the iterator.
35
     */
36
    abstract protected function getIteratorArray(): array;
37
}
38