Conditions | 6 |
Paths | 10 |
Total Lines | 25 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 6.0087 |
Changes | 0 |
1 | <?php |
||
38 | 17 | protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) { |
|
39 | 17 | if ( $item instanceof \DOMDocument ) { |
|
40 | 16 | $directChildren = $item->documentElement->childNodes->item( 0 )->childNodes; |
|
41 | } else { |
||
42 | 16 | $directChildren = $item->childNodes; |
|
43 | 16 | } |
|
44 | 16 | ||
45 | 1 | if ( $directChildren->length === 0 ) { |
|
46 | $mismatchDescription->appendText( 'having no children' ); |
||
47 | return false; |
||
48 | 17 | } |
|
49 | 1 | ||
50 | 1 | if ( !$this->matcher ) { |
|
51 | return $directChildren->length > 0; |
||
52 | } |
||
53 | 16 | ||
54 | foreach ( new XmlNodeRecursiveIterator( $directChildren ) as $child ) { |
||
55 | if ( $this->matcher->matches( $child ) ) { |
||
56 | return true; |
||
57 | 16 | } |
|
58 | 16 | } |
|
59 | 10 | ||
60 | $mismatchDescription->appendText( 'having no children ' )->appendDescriptionOf( $this->matcher ); |
||
61 | 11 | return false; |
|
62 | } |
||
63 | 6 | ||
65 |