XmlNodeRecursiveIterator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addElementsToQueue() 0 11 3
1
<?php
2
3
namespace WMDE\HamcrestHtml;
4
5
class XmlNodeRecursiveIterator extends \ArrayIterator {
6
7 18
	public function __construct( \DOMNodeList $nodeList ) {
8 18
		$queue = $this->addElementsToQueue( [], $nodeList );
9 18
		parent::__construct( $queue );
10 18
	}
11
12
	/**
13
	 * @param \DOMNode[] $queue
14
	 * @param \DOMNodeList $nodeList
15
	 *
16
	 * @return \DOMNode[] New queue
17
	 */
18 18
	private function addElementsToQueue( array $queue, \DOMNodeList $nodeList ) {
19
		/** @var \DOMNode $node */
20 18
		foreach ( $nodeList as $node ) {
21 18
			$queue[] = $node;
22 18
			if ( $node->childNodes !== null ) {
23 18
				$queue = $this->addElementsToQueue( $queue, $node->childNodes );
24 18
			}
25 18
		}
26
27 18
		return $queue;
28
	}
29
30
}
31