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 | 16 | } else { |
|
42 | 1 | $directChildren = $item->childNodes; |
|
43 | } |
||
44 | |||
45 | 17 | if ( $directChildren->length === 0 ) { |
|
46 | 1 | $mismatchDescription->appendText( 'having no children' ); |
|
47 | 1 | return false; |
|
48 | } |
||
49 | |||
50 | 16 | if ( !$this->matcher ) { |
|
51 | return $directChildren->length > 0; |
||
52 | } |
||
53 | |||
54 | 16 | foreach ( new XmlNodeRecursiveIterator( $directChildren ) as $child ) { |
|
55 | 16 | if ( $this->matcher->matches( $child ) ) { |
|
56 | 10 | return true; |
|
57 | } |
||
58 | 11 | } |
|
59 | |||
60 | 6 | $mismatchDescription->appendText( 'having no children ' )->appendDescriptionOf( $this->matcher ); |
|
61 | 6 | return false; |
|
62 | } |
||
63 | |||
65 |