TextContentsMatcher   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 45.45%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 36
ccs 5
cts 11
cp 0.4545
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A havingTextContents() 0 3 1
A __construct() 0 4 1
A describeTo() 0 3 1
A matchesSafelyWithDiagnosticDescription() 0 3 1
1
<?php
2
3
namespace WMDE\HamcrestHtml;
4
5
use Hamcrest\Description;
6
use Hamcrest\Matcher;
7
use Hamcrest\Util;
8
9
class TextContentsMatcher extends TagMatcher {
10
11
	/**
12
	 * @var Matcher
13
	 */
14
	private $matcher;
15
16
	/**
17
	 * @param Matcher|string $text
18
	 *
19
	 * @return self
20
	 */
21
	public static function havingTextContents( $text ) {
22
		return new static( Util::wrapValueWithIsEqual( $text ) );
23
	}
24
25
	public function __construct( Matcher $matcher ) {
26
		parent::__construct();
27
		$this->matcher = $matcher;
28
	}
29
30 2
	public function describeTo( Description $description ) {
31 2
		$description->appendText( 'having text contents ' )->appendDescriptionOf( $this->matcher );
32 2
	}
33
34
	/**
35
	 * @param \DOMElement $item
36
	 * @param Description $mismatchDescription
37
	 *
38
	 * @return bool
39
	 */
40 4
	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
41 4
		return $this->matcher->matches( $item->textContent );
42
	}
43
44
}
45