GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#9)
by no
09:19
created

matchesSafelyWithDiagnosticDescription()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 7.456

Importance

Changes 0
Metric Value
cc 4
eloc 10
nc 4
nop 2
dl 0
loc 15
ccs 4
cts 10
cp 0.4
crap 7.456
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
namespace WMDE\HamcrestHtml;
4
5
use Hamcrest\Description;
6
use Hamcrest\Matcher;
7
8
class ClassMatcher extends TagMatcher {
9
10
	/**
11
	 * @var Matcher|string
12
	 */
13
	private $classMatcher;
14
15
	/**
16
	 * @param Matcher|string $class
17
	 *
18
	 * @return self
19
	 */
20
	public static function withClass( $class ) {
21
		return new static( $class );
22
	}
23
24
	/**
25
	 * @param Matcher|string $class
26
	 */
27
	public function __construct( $class ) {
28
		parent::__construct();
29
		$this->classMatcher = $class;
30
	}
31
32 1 View Code Duplication
	public function describeTo( Description $description ) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33 1
		$description->appendText( 'with class ' );
34 1
		if ( $this->classMatcher instanceof Matcher ) {
35
			$description->appendDescriptionOf( $this->classMatcher );
36
		} else {
37 1
			$description->appendValue( $this->classMatcher );
38
		}
39 1
	}
40
41
	/**
42
	 * @param \DOMElement $item
43
	 * @param Description $mismatchDescription
44
	 *
45
	 * @return bool
46
	 */
47 5
	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
48 5
		$classAttribute = $item->getAttribute( 'class' );
49
50 5
		if ( $this->classMatcher instanceof Matcher ) {
51
			$classes = preg_split( '/\s+/u', $classAttribute );
52
			foreach ( $classes as $class ) {
53
				if ( $this->classMatcher->matches( $class ) ) {
54
					return true;
55
				}
56
			}
57
			return false;
58
		} else {
59 5
			return (bool)preg_match( '/(^|\s)' . preg_quote( $this->classMatcher, '/' ) . '(\s|$)/u', $classAttribute );
60
		}
61
	}
62
63
}
64