ArrayNode::count()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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