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

TagNameMatcher   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 60
Duplicated Lines 15 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
dl 9
loc 60
ccs 13
cts 26
cp 0.5
rs 10
c 0
b 0
f 0
wmc 9
lcom 1
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A withTagName() 0 3 1
A __construct() 0 4 1
A describeTo() 8 8 2
B matchesSafelyWithDiagnosticDescription() 0 19 5

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace WMDE\HamcrestHtml;
4
5
use Hamcrest\Description;
6
use Hamcrest\Matcher;
7
8
class TagNameMatcher extends TagMatcher {
9
10
	/**
11
	 * @var Matcher|string
12
	 */
13
	private $tagNameMatcher;
14
15
	/**
16
	 * @param Matcher|string $tagName
17
	 *
18
	 * @return self
19
	 */
20
	public static function withTagName( $tagName ) {
21
		return new static( $tagName );
22
	}
23
24
	/**
25
	 * @param Matcher|string $tagNameMatcher
26
	 */
27
	public function __construct( $tagNameMatcher ) {
28
		parent::__construct();
29
		$this->tagNameMatcher = $tagNameMatcher;
30
	}
31
32 5 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 5
		$description->appendText( 'with tag name ' );
34 5
		if ( $this->tagNameMatcher instanceof Matcher ) {
35
			$description->appendDescriptionOf( $this->tagNameMatcher );
36
		} else {
37 5
			$description->appendValue( $this->tagNameMatcher );
38
		}
39 5
	}
40
41
	/**
42
	 * @param \DOMElement $item
43
	 * @param Description $mismatchDescription
44
	 *
45
	 * @return bool
46
	 */
47 11
	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
48 11
		if ( $this->tagNameMatcher instanceof Matcher ) {
49
			if ( $this->tagNameMatcher->matches( $item->tagName ) ) {
50
				return true;
51
			}
52
		} else {
53 11
			if ( $item->tagName === $this->tagNameMatcher ) {
54 6
				return true;
55
			}
56
		}
57
58 8
		$mismatchDescription->appendText( 'tag name ' );
59 8
		if ( $this->tagNameMatcher instanceof Matcher ) {
60
			$this->tagNameMatcher->describeMismatch( $item->tagName, $mismatchDescription );
61
		} else {
62 8
			$mismatchDescription->appendText( 'was ' )->appendValue( $item->tagName );
63
		}
64 8
		return false;
65
	}
66
67
}
68