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.
Completed
Pull Request — master (#2)
by Leszek
05:10
created

containsStringIgnoringWhiteSpace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace WMDE\HamcrestHtml;
4
use Hamcrest\Text\SubstringMatcher;
5
6
class StringContainsIgnoringWhiteSpace extends SubstringMatcher
7
{
8 7
	public function __construct($substring)
9
	{
10 7
		parent::__construct($this->_stripSpace($substring));
11 7
	}
12
13
	/**
14
	 * Matches if value is a string that contains $substring consider all whitespace as single space
15
	 */
16 7
	public static function containsStringIgnoringWhiteSpace($substring)
17
	{
18 7
		return new self($substring);
19
	}
20
21
	/**
22
	 * @param \DOMElement $item
23
	 *
24
	 * @return bool
25
	 */
26 7
	protected function evalSubstringOf($item)
27
	{
28 7
		return (false !== strpos($this->_stripSpace((string) $item), $this->_substring));
29
	}
30
31
	protected function relationship()
32
	{
33
		return 'containing';
34
	}
35
36
	/**
37
	 * Copied from IsEqualIgnoringWhiteSpace
38
	 *
39
	 * @param $string
40
	 *
41
	 * @return string
42
	 */
43 8
	private function _stripSpace($string)
44
	{
45 8
		$parts = preg_split("/[\r\n\t ]+/", $string);
46 8
		foreach ($parts as $i => $part) {
47 8
			$parts[$i] = trim($part, " \r\n\t");
48 8
		}
49
50 8
		return trim(implode(' ', $parts), " \r\n\t");
51
	}
52
}
53