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
02:41
created

matchesSafelyWithDiagnosticDescription()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
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 16
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
    /**
12
     * @var Matcher|string
13
     */
14
    private $classMatcher;
15
16
    /**
17
     * @param Matcher|string $class
18
     *
19
     * @return self
20
     */
21
    public static function withClass($class) {
22
        return new static($class);
23
    }
24
25
    /**
26
     * @param Matcher|string $class
27
     */
28
    public function __construct($class)
29
    {
30
        parent::__construct();
31
        $this->classMatcher = $class;
32
    }
33
34 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...
35
    {
36 1
        $description->appendText('with class ');
37 1
        if ($this->classMatcher instanceof Matcher) {
38
            $description->appendDescriptionOf($this->classMatcher);
39
        } else {
40 1
            $description->appendValue($this->classMatcher);
41
        }
42 1
    }
43
44
    /**
45
     * @param \DOMElement $item
46
     * @param Description $mismatchDescription
47
     *
48
     * @return bool
49
     */
50 5
    protected function matchesSafelyWithDiagnosticDescription($item, Description $mismatchDescription)
51
    {
52 5
        $classAttribute = $item->getAttribute('class');
53
54 5
        if ($this->classMatcher instanceof Matcher) {
55
            $classes = preg_split('/\s+/u', $classAttribute);
56
            foreach ($classes as $class) {
57
                if ($this->classMatcher->matches($class)) {
58
                    return true;
59
                }
60
            }
61
            return false;
62
        } else {
63 5
            return (bool)preg_match('/(^|\s)' . preg_quote($this->classMatcher, '/') . '(\s|$)/u', $classAttribute);
64
        }
65
    }
66
67
}
68