Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
DiffDOMUtils
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 hasNChildren
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 firstNonSepChild
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 nextNonSepSibling
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2declare( strict_types = 1 );
3
4namespace Wikimedia\Parsoid\Ext;
5
6use Wikimedia\Parsoid\DOM\Node;
7use Wikimedia\Parsoid\Utils\DiffDOMUtils as DDU;
8
9class DiffDOMUtils {
10
11    /**
12     * Test the number of children this node has without using
13     * `DOMNode::$childNodes->count()`.  This walks the sibling list and so
14     * takes O(`nchildren`) time -- so `nchildren` is expected to be small
15     * (say: 0, 1, or 2).
16     *
17     * Skips all diff markers by default.
18     * @param Node $node
19     * @param int $nchildren
20     * @param bool $countDiffMarkers
21     * @return bool
22     */
23    public static function hasNChildren(
24        Node $node, int $nchildren, bool $countDiffMarkers = false
25    ): bool {
26        return DDU::hasNChildren( $node, $nchildren, $countDiffMarkers );
27    }
28
29    /**
30     * Get the first child element or non-IEW text node, ignoring
31     * whitespace-only text nodes, comments, and deleted nodes.
32     *
33     * @param Node $node
34     * @return Node|null
35     */
36    public static function firstNonSepChild( Node $node ): ?Node {
37        return DDU::firstNonSepChild( $node );
38    }
39
40    /**
41     * Get the next non separator sibling node.
42     *
43     * @param Node $node
44     * @return Node|null
45     */
46    public static function nextNonSepSibling( Node $node ): ?Node {
47        return DDU::nextNonSepSibling( $node );
48    }
49
50}